I'm trying to fit a mixed model in R.
Actually I have a Stata code and want to do the same thing using R.
The Stata code is
xtmixed laz c.x1##i.j4alloc_n c.x2##i.j4alloc_n ||childuid:age_m, cov(uns) var
I can't find how to specify 'unstructured' correlation structure in R.
In the R help file, there is no 'unstructured'
https://stat.ethz.ch/R-manual/R-devel/library/nlme/html/corClasses.html
Related
I would like to run a mixed model in R specifycing the object for the structure of a random effect.
My model is this:
model1=lme(methane~fixedfactor1,
random=(~1|factory),
data=df,method="REML")
I have then an object named "factory_relationship" that I would like to use to model the structure of the random effect "factory".
If it can help, I did it in SAS by using the following:
proc mixed data=methane_data NOINFO;
class fixedfactor1;
model methane= fixedfactor1;
random factory/type=lin(1) LDATA=factory_relationship;
run;
However, I could not find any solutions in R.
Could you please help me?
Best
I tried to read the PDF guidelines for both "nlme" and "lme4" R packages, but I could not find any hint.
I am new to using R as I usually use Stata. I want to estimate a state space model on some time series data with time varying coefficients. From what I have gathered this is not possible to do in Stata.
I have downloaded the dlm package in R and I am trying to run the dlmModReg command to regress my dependent variable on a single explanatory variable. I would like to allow the intercept and beta coefficient to vary over time.
If anyone could show me an example of the code I want to run I think that would be enough for me to work out how to do this. The examples I have found online are vague or use terminology that I am not familiar with as a new R user. Any help or comments are greatly appreciated.
I'm really confused about regression models and functions in R. Here is my problem. I'm using the PLS package to make a model like Y~x. To do that I have to use 'plsr':
model=plsr(Y~X,ncomp=10,data=df1,center=TRUE, scale=TRUE, validation="LOO")
I couldn't find the source of the 'plsr' in the PLS source code but in the help document it says it refers to 'mvr{pls}' which I could find it. first is 'plsr' a function or model.. in the R terminology? is it built in R? and how does it refer to 'mvr' function in pls package?
Thanks
I am trying to fit a transfer function model using R in order to apply the fitted model to a validation set of data, because SPSS doesn't allow me to (or I don't know how to) compute point forecasts just like the function Arima() from forecast package does. It does let me apply the model, but it does not use the dependet variable's lagged values, that's why I am trying R.
Anyone know how I could get those type of "updated" or validation forecasts using the arimax() function? I am not looking for the following type of predictions:
predict(vixari011, n.ahead=12)
But rather these:
Arima(test$VIX, model = vixari)
From what I have been reading there is no prediction function for the arimax() function, any ideas about how I could forecast to evaluate point-by-point performance? I can just think of computing manually using a spreadsheet...
I had the same problem. I know this post is old but this can help someone.
I used this it worked just fine
forecast(fitted(arimax_ts_model), h=11)
My colleague and I chose Stata for regression analysis due to good handling of survey data. We also want to use R for graphics, but do not know how to export Stata regression model.
Within Stata, of course there is return list and ereturn list. But what's the best way to export these results outside of Stata? Direct to R would be ideal, but any intermediate format would be fine as well.
If I were to do this, I would create a Stata dataset with all the regression results using postfile. Then import it into R using, for example, some technique from here. Manipulate within R at your convenience.
See also the user-written command rsource: ssc describe rsource.
Disclaimer: my knowledge of R is rather limited.
I would advise using regsave
ssc install regsave
E.g. after a regression command you could use
regsave, tstat pval ci
to replace the current dataset by the estimation results and save it afterwards.