Recent content by starpen

  1. S

    Learning to make programs

    Hey guys. So I'm learning to program ado's and I have a question. Say I want to make a random joke generator in stata from a list of 100 jokes. How do I make the program select a random statement from a list of statements? For example: program define joke version 14.0 dis as text "joke...
  2. S

    Change score in long format

    Hey guys. So I'm working on data and need to compute a change score. The data is panel data, where ID is country and I have 12 years. Here's my problem. I need to drop all years between 2000 and 2011 and compute a change score between 2000 and 2011. The drop part isn't the problem but the...
  3. S

    R essentials for SPSS

    Hey guys. So I've been working with STATA for a long time and I need to show some things in SPSS since I teach a course on specific statistical methods in a university where SPSS is the main program. I need to teach propensity score matching and 2-step regression (Heckman) but I see that...
  4. S

    Generating segregation variable

    Hey guys. I know this is really simple, I just can't figure it out and it's bugging me! So I have two variables: one is school ID (arbitrary number that functions as ID variable) and a dummy variable that shows if the children has 0 both parents native or 1 one or both parents imigrants...
  5. S

    Dropping duplicates with date-specific properties

    Hey guys. I had a question today that I had no idea how to solve. It basically revolves around removing duplicates from a dataset with close to 28.000 observations. There is a unique ID for each person and then a date of admittance. The problem is; it is only the first occurrence sorted by...
  6. S

    Error using xtregfem

    Hey guys. I've been trying to run a user-written program to do a ridge and weighted fixed effects panel data regression called xtregfem but I can't get it to work. What I do is: *******example******* xtregfem hea gdpln postin labforfem, id(country) it(year) ******example end*******...
  7. S

    Fixing multicollinearity in panel data regression

    Hey guys. It's a big question in short format; I have data from 42 countries over 12 years and one of my independent variables is GDP (transformed by ln). I have a few other macro level variables and I would like to run some pooled models but I run into trouble - I have a lot of...
  8. S

    xtreg with year as independent

    Hey guys. So this might be a silly question but I'll ask anyway. If I just want to check, if the passing of years have any effect on my dependent variable in panel data, what should I do? xtreg already utilizes "year" as time, so I'm thinking that I need something else. I came up with this...
  9. S

    Visualizing panel data

    Hey guys. So I have a non-technical problem. I'm doing longitudinal studies with 44 countries over 11 years and I really want to do something visual to present the data but I am at a loss as to how one does this without it being completely ridiculous to read. It's 44 values x 11 so whenever I...
  10. S

    Regression diagnostics on panel data regression

    Hey guys. I've not worked much in panel data regression but what I've been thinking about (and not been able to find much information about) is post diagnostics for fixed effects panel data regression (yit = alpha + XB + ui + eit). Is it possible to be able to do residual analysis...
  11. S

    Multiple encode commands with foreach

    So I have a bunch of string variables that cannot be destringed and encode does the job. However, I have many and found this code especially compelling since it uses the names of the other variables so I don't have to do a lot of renaming. However I hit a snag; I get an error from this telling...
  12. S

    Long to wide

    Hey guys. I''ve finally gathered the last of the data I need to do some longitudinal research but then I hit a snag. As far as I know, my data is on long format and someone told me, that it needs to be in wide format. Now I just have one variable for year, one for country (dummy) and then a...
  13. S

    Auto fill string ID variable

    Hey guys. So I've been working on a project where I need to code a load of surveys. Each survey has (in groups of maybe 100) a specific group identifier and then a personal ID. Something like this: N15-01 N15-02 N15-03 ect. for group one and then again for the next group: N16-01...
  14. S

    Loop do-file with a few adjustments

    Hey guys. So I've made a long do-file and I was wondering if there were a clever way to repeat parts of the do-file with a few changes? I'm doing a series of cross-national tests and I want to see what happens if I drop a single country and run all the tests again. Basicly I want this...
  15. S

    Non normality in residuals in SLR

    Hey guys. I've done a SLR and after testing the residuals for normality using the Shapiro-Wilk test and I've learned that the residuals are not normal. What does this mean? Is the test useless or can it be saved? Should I use another test to test my two variables?