# Plots-Tables of Interpreting Parameter Estimates in the Final Model from STATA and SAS to R

Hi Community

Im need replicate the chapter 8 of this book (pag 390), somes parts are in STATA, SAS and R. Im need make all in R.

Im can replicate many things of this chapter but I have problem with somes tables and plots, because the book make this in Stata. Im have the linear mix model but dont know how make this plot and tables.

Chapter
8.7 Interpreting Parameter Estimates in the Final Model

``````#code of STATA
* Model 8.1, with plots of marginal predicted values.
. mixed math year || _all: R.studid || _all: R.tchrid, variance reml
. margins, at(year = (-1,0,1))
. marginsplot
``````

Im need to make this table .

8.8 The Implied Marginal Variance-Covariance Matrix for
the Final Model

``````# code of SAS
random int / subject = studid v vcorr;
``````

Model

``````library(lmerTest)
attach(sat)
model8.1<- lmer(math ~ year + (1|studid) + (1|tchrid), REML = T)
``````

Data

``````sat<-structure(list(studid = c(13099, 13100, 13100, 13100, 13101,
13101, 13102, 13102, 13102, 13103, 13103, 13104, 13104, 13104,
13105, 13105, 13105, 13106, 13106, 13106, 13107, 13107, 13107,
13108, 13109, 13110, 13111, 13111, 13112, 13113, 13114, 13114,
13114, 13115, 13115, 13115, 13116, 13116, 13117, 13117, 13117,
13118, 13118, 13119, 13119, 13119, 13120, 13120, 13121, 13121,
13121, 13122, 13122, 13122, 13123, 13124, 13124, 13124, 13125,
13126), tchrid = c(14433, 14433, 14484, 14755, 14433, 14494,
14433, 14494, 14545, 14433, 14494, 14405, 14433, 14694, 14433,
14494, 14545, 14433, 14494, 14545, 14433, 14494, 14545, 14433,
14433, 14433, 14433, 14494, 14433, 14433, 14433, 14494, 14545,
14433, 14494, 14545, 14494, 14545, 14433, 14494, 14545, 14433,
14494, 14433, 14494, 14545, 14433, 14494, 14433, 14494, 14545,
14433, 14494, 14545, 14433, 14433, 14494, 14755, 14433, 14443
), math = c(631, 596, 575, 591, 615, 590, 621, 624, 611, 604,
613, 685, 656, 633, 593, 638, 620, 621, 638, 629, 598, 633, 620,
646, 627, 536, 606, 646, 577, 604, 642, 666, 705, 598, 617, 626,
615, 638, 596, 628, 635, 579, 563, 586, 604, 642, 563, 594, 624,
598, 605, 627, 633, 638, 591, 567, 626, 620, 591, 546), year = c(-1,
-1, 0, 1, -1, 0, -1, 0, 1, -1, 0, 1, -1, 0, -1, 0, 1, -1, 0,
1, -1, 0, 1, -1, -1, -1, -1, 0, -1, -1, -1, 0, 1, -1, 0, 1, 0,
1, -1, 0, 1, -1, 0, -1, 0, 1, -1, 0, -1, 0, 1, -1, 0, 1, -1,
-1, 0, 1, -1, -1)), row.names = c(NA, -60L), class = c("tbl_df",
"tbl", "data.frame"))
``````

Thanks for somes advances .

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.