[R] extractModelParameters HELP!!!

2011-03-05 Thread vaibhav dua
Hello Gurus,

I'm using one of the function, i.e. extractModelParameters, from the 
MplusAutomation package to read parameters fromMplus out files into R. I have 
360 cells and each cell has several out files (max. 100). I'm extracting the 
model parameters from each cell and doing subsequent calculations, primarily, 
on 
'est.' column. The following code demonstrates how I'm extracting the 
parameters 
and referencing the est. column:

CurrentDir = 
paste("D:/Dissertation/Mplus_Output_2Class_LGMM/",a,"-",b,"-",c,"-",d,"-",e,"-",f,
 sep="")
modelResults <- extractModelParameters(CurrentDir, recursive=FALSE,
dropDimensions=TRUE)
numReps = length(list.files(CurrentDir, pattern="*.out"))

after the above code is executed, 'modelResults' has all the data from the out 
files as different elements of the returned list. I'm accessing est. column 
from 
each element in the following way:

for (g in 1:numReps)
MeansTempC1[counterC1]  <- modelResults[[g]]$est[31]

I'm able to get the values from the est. column successfully for 359 cells 
which 
consist of 29532  out files. For just 1 particular cell, when I try to access 
the est. column or any other column in that out file, i.e. est_se or 
paramHeader, i get the value of NULL and I'm not able to figure out why. The 
same code is working for 29532 out files but not for 70 files in that 1 cell. I 
would really appreciate if you can assist me troubleshoot this issue. I have 
been working on this problem since last Sunday and after spending 6 days I 
still 
not able to figure out the problem.

Your help is truly appreciated.

Regards
Vaib


  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.


[R] remove quotes from the paste output

2010-12-11 Thread vaibhav dua
Hi,

I'm generating the name of the variable with paste function and then using that 
variable name further to get the specific position value from the data.frame, 
here is the snippet from my code:

modelResults <- extractModelParameters("C:/PilotStudy/Mplus_Input/Test", 
recursive=TRUE)

#extractModelParameters reads all the output files from the Test folder and 
create the following variables in R for each file read:
#C..PilotStudy.Mplus_Input.Test.rep1.out.unstandardized.est
#C..PilotStudy.Mplus_Input.Test.rep2.out.unstandardized.est
#C..PilotStudy.Mplus_Input.Test.rep3.out.unstandardized.est

modelResultsTemp <- as.data.frame(modelResults)

MeansTempC1 = rep(NA ,9)
counter = 1

for (f in 1:3)
{
i=31

for (g in 1:3)
{
OutputFileName <- 
paste("modelResultsTemp$C..PilotStudy.Mplus_Input.Test.rep",f,".out.unstandardized.est[",i,"]",sep="")

MeansTempC1[counter] = OutputFileName
i=i+1
counter = counter+1
}
}

Its not giving me any error but I'm not getting the desired output in 
MeansTempC1 because OutputFileName is a string and thats why its not returning 
the OutputFileName[31] etc. Does anybody know how to eliminate the double 
quotes 
so that I can use the variable name (generated with the paste function) further 
in the code

Regards
Bob



  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.


[R] Generate Univariate Normal Mixtures???

2010-02-19 Thread vaibhav dua


Hi,

I'm trying to generate a mixture from 2 univariate normal distributions and 
would like to put a constrained on the means (Equal) of the two distributions. 
Here is my shot at the code:

library(nor1mix)

X <- norMix(mu=c(50, 60 ), sig2=c(5,10), w=c(0.5, 0.5))

mixData <- rnorMix(1000, X)

plot(mixData, type="l")


I did get the 1000 random numbers in equal proportion but how can I confirm if 
the means was constrained or not in the data generation process?

Any help will be highly appreciated

VD



  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.



  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.


[R] Univariate Normal Mixtures - HELP

2010-02-18 Thread vaibhav dua
Hi,
 
I'm generating a mixture of 2 univariate normal distributions using norMix and 
rnorMix and would like to put a constraint on Mean (Equal). here is my code 
snippet:

library(nor1mix)

X <- norMix(mu=c(50, 60 ), sig2=c(5,10), w=c(0.5, 0.5))

mixData <- rnorMix(1000, X)

plot(mixData, type="l")


I do get the 1000 random numbers in equal proportion but I want to confirm if 
the Mean is same or not

Any help will be highly appreciated

Victor



  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.


[R] HELP on Non-Linera Mixed-Effect model

2010-02-15 Thread vaibhav dua
Hi,

I'm trying to fit nonlinear mixed effects model using nlme function but getting 
an error message. Here is what I have:

fitted_model = nlme(scores~spline(b1,b2,b3,kt,time), 
   fixed = list(b1~1, b2~1, b3~1, kt~1),
   random = b1+b2+b3~1, 
   groups= ~id,
   data = sdat,
   start = c(b1=3.5,b2=2,b3=.60,kt=3.5),verbose=T)


Error:

Error in spline(b1, b2, b3, kt, time) : invalid interpolation method
In addition: Warning message:
In if (is.na(method)) stop("invalid interpolation method") :
  the condition has length > 1 and only the first element will be used

Any help will be highly appreciated

Victor


  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.


Re: [R] rlaplace using rmutil - HELP

2010-02-15 Thread vaibhav dua
Hi Peter,

Thanks for quick reply. Like I said that I'm aware that it needs a vector but I 
want to use diagonal matrix. 

As you have noted, It could be possible that rlaplace reading dispDiag as a 
vector and not matrix like c(3,0,0,0,.20,0,0,0,.1) so I thought to change the 
code little bit:


dispersion = c(3,.20,.10)
dispDiag = diag(dispersion)
location = c(0,0,0)
output = (rlaplace(3, location, as.matrix(dispDiag)))

but still get the same output.

I want to draw random deviates from multivariate laplace distribution. Do you 
think rlaplace in VGAM can help?

Victor





From: Peter Ehlers 

Cc: r-help@r-project.org
Sent: Mon, February 15, 2010 10:52:33 AM
Subject: Re: [R] rlaplace using rmutil - HELP

On 2010-02-15 8:26, vaibhav dua wrote:
> Hi,
>
> I'm using rlaplace distribution to draw non normal random deviates. I'm using 
> rmutil package for this. I know rlaplace needs location and dispersion 
> parameters but I want to pass diag matrix as dispersion parameters and I'm 
> not getting the correct values. Here is my code snippet:
>
>  dispersion = c(3,.20,.10)
>  dispDiag = diag(dispersion)
>  location = c(0,0,0)
>  output = (rlaplace(3, location, dispDiag))
>
>
> Here is what I get:
>
>   -0.8475811  0.000  0.000
>
> I dont know why it is returning 0's at 2nd and 3rd place. If I change the 
> values in location vector, it simply picks up the value and replace it at 2nd 
> and 3rd place.
>
> You help will be highly appreciated
>
> Victor

If you read the help page carefully, you'll see that rlaplace()
wants a *vector* of dispersion parameters. So why not just use

  rlaplace(3, location, dispersion)

With dispDiag, rlaplace is probably taking 's' to be
c(3,0,0,0,.20,0,0,0,.1) and is only using the first three elements.
(Untested)

In case you're not aware: there's also rlaplace() in the VGAM package.

  -Peter Ehlers

>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> 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.
>
>

-- 
Peter Ehlers
University of Calgary



  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.


[R] rlaplace using rmutil - HELP

2010-02-15 Thread vaibhav dua
Hi, 

I'm using rlaplace distribution to draw non normal random deviates. I'm using 
rmutil package for this. I know rlaplace needs location and dispersion 
parameters but I want to pass diag matrix as dispersion parameters and I'm not 
getting the correct values. Here is my code snippet:

dispersion = c(3,.20,.10)
dispDiag = diag(dispersion)
location = c(0,0,0)
output = (rlaplace(3, location, dispDiag))


Here is what I get:

 -0.8475811  0.000  0.000

I dont know why it is returning 0's at 2nd and 3rd place. If I change the 
values in location vector, it simply picks up the value and replace it at 2nd 
and 3rd place.

You help will be highly appreciated

Victor


  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.