title: Converting SAS code to R code
body: <p>I have been trying to convert a SAS code that calculates Simple Regression and Mixed Models. I've achieved to convert simple Regression but when it comes to Mixed Model, my trials turn into fails. The SAS code shnown below is the code that I try to convert</p>
  
  <p>"parc" "m" "dap" "ht" is the header labes of dataset, respectively.</p>
  
  <pre><code>data algoritmo ;
  input parc m dap ht ;
  lnH = LOG(ht-1.3);
  lnD = LOG(dap) ;
  cards ;
  8   1   24.3    26.7
  8   1   29.9    30.7
  8   1   32.6    31.7
  8   1   35.9    33.7
  8   1   36.5    32.5
  22  2   22.3    21.0
  22  2   26.9    23.1
  22  2   26.9    20.5
  22  2   32.4    21.5
  22  2   33.5    25.0
  85  3   33.6    33.5
  85  3   36.0    33.0
  85  3   37.0    35.0
  85  3   40.8    35.0
  
  ;
  run ;
  
  /* Simpre Regression Model */
  PROC REG DATA=algoritmo ;
  model lnH = lnD ;
  output out=out p=pred ;
  run ; quit ;
  
  /* Mixed-Effects Model */
  PROC MIXED DATA=algoritmo COVTEST METHOD=REML  ;
  TITLE ' lnH = (B0+bok)+(B1+b1k)*lnd ' ;
  MODEL lnH = lnD / S OUTPM=outpm OUTP=outp ;
  RANDOM intercept lnD /SUBJECT=m s G TYPE=UN ;
  RUN ;
  </code></pre>
  
  <p>Here is the part of code that I converted. This part of code works perfect for me. </p>
  
  <pre><code>data1= read.table(file.choose(), header=T, sep=",")
  attach(data1)
  lnH=log(ht-1.3)
  lnD =log(dap)
  data2 = cbind(data1,lnH, lnD)
  #Simple Linear Model
  model1 = lm(lnH~lnD,data=data2)
  summary(model1)
  </code></pre>
  
  <p>But for the rest I'm stuck.</p>
  
  <pre><code>model2 = lme(lnH~lnD ,data=data2,random=~1|lnD / m, method= "REML",  weights=varPower(0.2,form=~dap))
  summary(model2)
  </code></pre>