0

I tried to finish a homework in longitudinal data analysis. the question is to compare the difference in the cross-sectional and longitudinal effects of age (baseline cross-sectional:baseage, longtitudinal age: agechange) within a model.

the model I code like: fit<-lme(logfev1~baseage+agechange+height,random = ~1|id,correlation=corAR1(form=~visit|id),logfev1)

In Stata we just need to code like : test baseage=agechange, then the answer will shows: test baseage = change_age

[logfev1]baseage - [logfev1]change_age = 0

       chi2(  1) =    0.41
     Prob > chi2 =    0.5244

but in R I really don't know how to do the test (wald test).

  • If you need the dataset I could send to you, I don't know how to attach a dataset here. thx – Zhenyu Zhang Feb 15 '17 at 20:46
  • It doesn't seem like you are trying to program here, so maybe your question better belong on [stats.se] where questions about statistical test are on-topic. Otherwise you really should be very clear on what you mean by "the wald test" and describe what stats you need to calculate that value. Provide the relevant documentation from Stata if necessary. – MrFlick Feb 15 '17 at 20:50

1 Answers1

1

If you use the glmer instead of the lme method you can use summary(fit) and it will actually give you the Wald Test as a part of its output.

Or you can call the Anova(fit) from the car package on your lme and it will return a Wald's Chi Square result.

You can type ?glmer in the console of rStudio to read about it and if you install the car package and load it you can run ?Anova (captalized) to get the low down on the method there

sconfluentus
  • 4,693
  • 1
  • 21
  • 40