I am trying to reproduce some old SAS PROC MIXED code using R and nlme. The data consists of emission readings from vehicles and fuel properties. All variables are real numbers except "study" and "vehicle", which are character. Unfortunately, since the data are confidential, I'm unable to provide an example. The original SAS v6.12 code is provided below: ------------------------------------------------------------------ /* READ DATA */ DATA emiss; INFILE 'data.tab' LRECL=8000 FIRSTOBS=2 DLM='09'X MISSOVER DSD; INPUT study $ vehicle $ thc rv t5 t9 ar ol ox su bz; /* CREATE NEW VARIABLES */ ln_thc = log (thc); new = study||vehicle; /* PERFORM ANALYSIS */ PROC MIXED DATA=emiss MAXITER=1000 CONVH=1E-8 METHOD=REML NOCLPRINT NOITPRINT; CLASS new; MODEL ln_thc = rv t5 t9 ar ol ox su bz /S DDFM=RES; RANDOM int rv t5 t9 ar ol ox su bz /SUB=new; RUN; ------------------------------------------------------------------ The R code I've devised for the PROC MIXED statement is shown below: ------------------------------------------------------------------ FitTHC <- LME(ln_thc ~ rv + t5 + t9 + ar + ol + ox + su + bz, DATA = emiss, RANDOM = ??????? ) ------------------------------------------------------------------ As indicated, the problem I'm having is in constructing the equivalent code for the RANDOM and any remaining settings. I've tried RANDOM = ~1 + rv + t5 + t9 + ar + ol + ox + su + bz | new) but R hangs and never produces a result. Therefore, what is the equivalent code for the SAS RANDOM? Thanks!
Dear Dennis, Your question assumes that people know both SAS PROC MIXED and R nlme. Only a limited number of people do. Add the mathematical formulation of the model. That will increase the number of people that can help you. Adding the number of levels in each categorical variable and the number of observation per group is useful too. Best regards, ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey 2017-08-10 15:34 GMT+02:00 Dennis F. Kahlbaum <kbomb at umich.edu>:> I am trying to reproduce some old SAS PROC MIXED code using R and nlme. > The data consists of emission readings from vehicles and fuel properties. > All variables are real numbers except "study" and "vehicle", which are > character. Unfortunately, since the data are confidential, I'm unable to > provide an example. > > The original SAS v6.12 code is provided below: > > ------------------------------------------------------------------ > /* READ DATA */ > DATA emiss; > INFILE 'data.tab' LRECL=8000 FIRSTOBS=2 DLM='09'X MISSOVER DSD; > INPUT study $ vehicle $ thc rv t5 t9 ar ol ox su bz; > > /* CREATE NEW VARIABLES */ > ln_thc = log (thc); > new = study||vehicle; > > /* PERFORM ANALYSIS */ > PROC MIXED DATA=emiss MAXITER=1000 CONVH=1E-8 METHOD=REML NOCLPRINT > NOITPRINT; > CLASS new; > > MODEL ln_thc = rv t5 t9 ar ol ox su bz > /S DDFM=RES; > > RANDOM int rv t5 t9 ar ol ox su bz > /SUB=new; > RUN; > ------------------------------------------------------------------ > > The R code I've devised for the PROC MIXED statement is shown below: > > ------------------------------------------------------------------ > FitTHC <- LME(ln_thc ~ rv + t5 + t9 + ar + ol + ox + su + bz, > DATA = emiss, > RANDOM = ??????? ) > ------------------------------------------------------------------ > > As indicated, the problem I'm having is in constructing the equivalent > code for the RANDOM and any remaining settings. I've tried > > RANDOM = ~1 + rv + t5 + t9 + ar + ol + ox + su + bz | new) > > but R hangs and never produces a result. Therefore, what is the equivalent > code for the SAS RANDOM? > > Thanks! > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posti > ng-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
On 8/10/2017 8:34 AM, Dennis F. Kahlbaum wrote:> -- snip --I don't have real help, but I'll remind you that R is case sensitive, and it looks like that will be at least one problem in the solution your are working on below: lme not LME data not DATA random = RANDOM> ------------------------------------------------------------------ > > The R code I've devised for the PROC MIXED statement is shown below: > > ------------------------------------------------------------------ > FitTHC <- LME(ln_thc ~ rv + t5 + t9 + ar + ol + ox + su + bz, > DATA = emiss, > RANDOM = ??????? ) > ------------------------------------------------------------------ > > As indicated, the problem I'm having is in constructing the equivalent > code for the RANDOM and any remaining settings. I've tried > > RANDOM = ~1 + rv + t5 + t9 + ar + ol + ox + su + bz | new) > > but R hangsAre the items in your random formula columns in a dataframe named emiss? Do they have data types? Even if the data are proprietary some fake data can make the problem more concrete. You are saying "gets caught in a processing loop that produces no errors or warnings"???> and never produces a result. Therefore, what is the equivalent code > for the SAS RANDOM? > > Thanks! > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- -- Robert W. Baer, Ph.D. Professor of Physiology Kirksville College of Osteopathic Medicine A T Still University of Health Sciences 800 W. Jefferson St Kirksville, MO 63501 660-626-2321 Department 660-626-2965 FAX
Hi Thierry: Thank you for your response. I have been trying to resolve this issue for some time, without success. That's why I've posted the problem hoping that someone with both SAS and R experience would be able to help. As background, this SAS code has been used on many different data sets in the past. Each data set always consisted of the measured emissions over a given driving cycle (e.g. grams/mile of THC for the FTP cycle) versus the fuel properties of: RVP, temperature for 50% evaporation, temperature for 90% evaporation, aromatics, olefins, sulfur, oxygenate, and benzene. Each case also has an entry for the vehicle being tested and the name of the study. Since the input data set can vary, so can the number of observations and the level counts for the two categorical variables. I hope this helps clarify things. --Dennis On 8/11/17 8:25 AM, Thierry Onkelinx wrote:> Dear Dennis, > > Your question assumes that people know both SAS PROC MIXED and R nlme. > Only a limited number of people do. Add the mathematical formulation > of the model. That will increase the number of people that can help > you. Adding the number of levels in each categorical variable and the > number of observation per group is useful too. > > Best regards, > > ir. Thierry Onkelinx > Instituut voor natuur- en bosonderzoek / Research Institute for Nature > and Forest > team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance > Kliniekstraat 25 > 1070 Anderlecht > Belgium > > To call in the statistician after the experiment is done may be no > more than asking him to perform a post-mortem examination: he may be > able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher > The plural of anecdote is not data. ~ Roger Brinner > The combination of some data and an aching desire for an answer does > not ensure that a reasonable answer can be extracted from a given body > of data. ~ John Tukey > > 2017-08-10 15:34 GMT+02:00 Dennis F. Kahlbaum <kbomb at umich.edu > <mailto:kbomb at umich.edu>>: > > I am trying to reproduce some old SAS PROC MIXED code using R and > nlme. The data consists of emission readings from vehicles and > fuel properties. All variables are real numbers except "study" and > "vehicle", which are character. Unfortunately, since the data are > confidential, I'm unable to provide an example. > > The original SAS v6.12 code is provided below: > > ------------------------------------------------------------------ > /* READ DATA */ > DATA emiss; > INFILE 'data.tab' LRECL=8000 FIRSTOBS=2 DLM='09'X MISSOVER DSD; > INPUT study $ vehicle $ thc rv t5 t9 ar ol ox su bz; > > /* CREATE NEW VARIABLES */ > ln_thc = log (thc); > new = study||vehicle; > > /* PERFORM ANALYSIS */ > PROC MIXED DATA=emiss MAXITER=1000 CONVH=1E-8 METHOD=REML > NOCLPRINT NOITPRINT; > CLASS new; > > MODEL ln_thc = rv t5 t9 ar ol ox su bz > /S DDFM=RES; > > RANDOM int rv t5 t9 ar ol ox su bz > /SUB=new; > RUN; > ------------------------------------------------------------------ > > The R code I've devised for the PROC MIXED statement is shown below: > > ------------------------------------------------------------------ > FitTHC <- LME(ln_thc ~ rv + t5 + t9 + ar + ol + ox + su + bz, > DATA = emiss, > RANDOM = ??????? ) > ------------------------------------------------------------------ > > As indicated, the problem I'm having is in constructing the > equivalent code for the RANDOM and any remaining settings. I've tried > > RANDOM = ~1 + rv + t5 + t9 + ar + ol + ox + su + bz | new) > > but R hangs and never produces a result. Therefore, what is the > equivalent code for the SAS RANDOM? > > Thanks! > > ______________________________________________ > R-help at r-project.org <mailto:R-help at r-project.org> mailing list -- > To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > <https://stat.ethz.ch/mailman/listinfo/r-help> > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > <http://www.R-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > >[[alternative HTML version deleted]]
Hi Robert: Thanks for your response, as well. I'm sorry. As you've discovered, I made some capitalization errors when posting my R code. The actual R code does use "lme", "data", and "random". The dataframe is indeed named "emiss" and each item in the formula is a column in the dataframe. I used the following R code to read in the comma-delimited file (first line contains headings): emiss <- read.table("data.csv", header=TRUE, sep=",") # NA for missing data (default) A review of the dataframe "emiss" shows that all items, except "STUDY", "VEHICLE" and "NEW", are of type "num". The items "STUDY", "VEHICLE", and "NEW" are of type "factor". I will work on creating some "fake data". However, since I don't have SAS v6.12 anymore, I can't provide the so-called "correct results". As for the R hang, your wording is correct: "R gets caught in a processing loop that produces no errors or warnings", even after 15 minutes on an 8-core Mac Pro. As I recall, the SAS code produced an answer in 15 seconds or less on a single core Mac II back in 1999. Thanks again! --Dennis On 8/11/17 9:27 AM, Robert Baer wrote:> > > On 8/10/2017 8:34 AM, Dennis F. Kahlbaum wrote: >> -- snip -- > I don't have real help, but I'll remind you that R is case sensitive, > and it looks like that will be at least one problem in the solution > your are working on below: > lme not LME > data not DATA > random = RANDOM >> ------------------------------------------------------------------ >> >> The R code I've devised for the PROC MIXED statement is shown below: >> >> ------------------------------------------------------------------ >> FitTHC <- LME(ln_thc ~ rv + t5 + t9 + ar + ol + ox + su + bz, >> DATA = emiss, >> RANDOM = ??????? ) >> ------------------------------------------------------------------ >> >> As indicated, the problem I'm having is in constructing the >> equivalent code for the RANDOM and any remaining settings. I've tried >> >> RANDOM = ~1 + rv + t5 + t9 + ar + ol + ox + su + bz | new) >> >> but R hangs > Are the items in your random formula columns in a dataframe named > emiss? Do they have data types? Even if the data are proprietary > some fake data can make the problem more concrete. > You are saying "gets caught in a processing loop that produces no > errors or warnings"??? > >> and never produces a result. Therefore, what is the equivalent code >> for the SAS RANDOM? >> >> Thanks! >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >