Convert dataframe into time-series

Hello everyone,

I have some problems regarding my statistical model for my master's dissertation. The dataset that I have is country-year as is unit of analysis, and the frequency is one observation per year. I would like to convert it into a time-series which accounts for the difference between countries and does not treat them on the same way.

I have used as.ts but I do not know whether the outcome that I get is correct, and thats the unique thing I have to do. I have also introduced the splines manually. I was wondering if there any easier way to get it.

Hello, You probably want to use a panel specification. To do so you can use the package plm and use on the dataset the function pdata.frame()and specify the index variable (in your case probably id for individual index and year for the time index)
Once you've done that you can use function such as plm() to fit panel model (Fixed effect, random effect etc) or pglm::pglm() if you want to use logistic model.

Hi! So I should not convert the dataframe into a time-series to account for time effect? I have two models: 1) negative binomial because my data is really skewed and the standard deviation is really high; 2) and ordinal logit since the dependent variable for the second model is an indicator that ranges from 0 to 2.

Time effect are taken into account when you use panel data. but to do so you have to precise what are the index to use for the plm function :
panel<-plm(dataset, index=c("id","year"))
and when you estimate a model you want to make sure to precise twoways effect as an argument to the function.
and also your data might not be that skewed since I assume you estimated that std deviation while not taking into account country fixed effect so maybe try the pglm packages for your first logit.
I don't know about the ordinal one

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.