[R] R Crash -- R Gui crashes during MCMC iteration

2011-02-15 Thread Haillie

Hi I am posting to seek some advice regarding the R Gui 2.12.0 that keeps
freezing on my pc. 
I have been trying to run MCMC ordinal factanal code on my PC but the window
freezes everytime after 7001 iterations (total of 25 iterations). My
operating system is window vista 64-bit with 4.0 gb of memory. 
Here is the code that I was trying to run under MCMCpack. 

## installing packages 
install.packages("MCMCpack") 
install.packages("foreign") 

## calling libraries 
library(MCMCpack) 
library(foreign) 

## opening a data set on the desktop 
setwd("C:/Users/haillie/Desktop") 
UN2009<- read.csv("UN2009.csv") 

#calling libraries 
library(reshape) 
library(car) 

colname <- names(UN2009) 
## these are thevariables I want to recode 

UN2009[colname] <- 
   lapply(UN2009[colname], 
   function(x) recode(x, recodes = "8=NA", 
   as.factor.result = TRUE, as.numeric.result = FALSE)) 
## this applies the recode functionto all the variable I wantto recode 

## Ordinalfactanal Code 
un2009<-MCMCordfactanal(~R.64.6+R.64.10+R.64.16+R.64.17+R.64.18+R.64.19+R.64.20+R.64.21+R.64.23+R.64.28+R.64.31+R.64.34+R.64.37+R.64.39+R.64.42+R.64.44+R.64.47+R.64.48+R.64.50+R.64.52+R.64.53+R.64.54+R.64.55+R.64.56+R.64.57+R.64.59+R.64.66+R.64.69+R.64.27+R.64.71+R.64.89+R.64.90+R.64.91+R.64.93+R.64.94+R.64.98+R.64.99+R.64.105+R.64.88+R.64.106+R.64.87+R.64.92+R.64.95+R.64.97+R.64.147+R.64.160+R.64.170+R.64.172+R.64.173+R.64.174+R.64.175+R.64.176+R.64.148+R.64.150+R.64.151+R.64.152+R.64.156+R.64.157+R.64.195+R.64.185+R.64.188+R.64.209+R.64.197+R.64.189+R.64.238+R.64.254+R.64.282+R.64.292+R.64.296,
 
data=UN2009,lambda.constraints=list(R.64.18=list(2,"+")), factors=1,
burnin=5000, mcmc=20, thin=40, verbose=1000, L0=0.05, store.lambda=TRUE,
store.scores=TRUE, tune=1.2) 

The system is fine until I try to run the ordinalfactanal iterations I
am also using the most recent version of Tinn R with R gui. not at the same
time but they share the same window space. Could this be a problem? 
I do not think the data set I am using is too big ( dimension 193, 27). 

If anyone could help me gain some insight into this problem, I would greatly
appreciate it. Thank you very much and I hope to hear from you soon. 

Sincerely, 
Haillie 
  


-- 
View this message in context: 
http://r.789695.n4.nabble.com/R-Crash-R-Gui-crashes-during-MCMC-iteration-tp3308047p3308047.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Setting Lambda constraints for MCMC ordinal model

2011-02-18 Thread Haillie

post47 <-
MCMCordfactanal(~a1+a2+a3+a4+a5+a6+a7+a8+a9+a10+a11+a12+a13+a14+a15+a16+a17+a18+a19+a20+a21+a22+a23+a24+a25+a26+a27+a28+a29+a30+a31+a32+a33+a34+a35+a36+a37+a38,
 
data=un47,lambda.constraints=list(a8=list(2,"+")), factors=1, burnin=5000,
mcmc=20, thin=40, verbose=1000, L0=0.05, store.lambda=TRUE,
store.scores=TRUE, tune=1.2)

I have a question regarding setting lambda.constraints in the code above.
What is the criteria one should use for setting lambda constraint? For
example, why would you chose to set the 2nd factor loading of a8 as +
instead of choosing a different variables and factor loadings and setting it
to negative?

Above is a code for ordinal MCMC factanal model. Thank you very much in
advance and I hope to hear from you soon!



-- 
View this message in context: 
http://r.789695.n4.nabble.com/Setting-Lambda-constraints-for-MCMC-ordinal-model-tp3313777p3313777.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Saving summary outputs in a table form

2011-03-16 Thread Haillie
Dear R help,

Is there a way to extract a variable ( one column) from my summary
statistics to save it in a table form?
My post-factor analysis summary statistics gave me the output below. Is
there anyway to just save the mean of all the phi? The filename of this
summary output is postun2010sum. Also is there a way to just save phi(,2) or
phi(,3) in a table form on my desktop? Any help would be deeply appreciated.
Thank you very much and I would be grateful for any comments.

  Mean  SD  Naive SE Time-series SE
LambdaR.64.6.1   -2.441402 0.37438 0.0118390  0.0099447
LambdaR.64.6.20.918276 0.34265 0.0108355  0.0101326
LambdaR.64.6.30.216445 0.32877 0.0103965  0.0108384
LambdaR.64.10.1  -0.269011 0.16282 0.0051488  0.0078555
LambdaR.64.10.2   1.379486 0.20658 0.0065327  0.0070898
LambdaR.64.10.3   0.235941 0.15448 0.0048851  0.0063958
phi.1.2   1.095283 0.11438 0.0036170  0.0060156
phi.1.3  -0.141687 0.16288 0.0051507  0.0101297
phi.2.2   0.890038 0.11511 0.0036401  0.0057195
phi.2.3   0.104225 0.15570 0.0049238  0.0090702
phi.3.2  -0.379830 0.21483 0.0067936  0.0078231
phi.3.3  -0.266584 0.32148 0.0101661  0.0102912
phi.4.2  -1.056815 0.37530 0.0118682  0.0149568
phi.4.3  -1.193200 0.31209 0.0098691  0.0129749
phi.5.2   0.364988 0.16384 0.0051812  0.0084784
phi.5.3  -1.324649 0.18231 0.0057652  0.0063309
phi.6.2  -1.078973 0.41542 0.0131368  0.0154569
phi.6.3   0.275169 0.44999 0.0142300  0.0157746
phi.7.2  -1.055651 0.36960 0.0116879  0.0132779
phi.7.3   0.664266 0.47810 0.0151190  0.0169993
phi.8.2  -0.869908 0.34998 0.0110672  0.0111003
phi.8.3   0.276252 0.42348 0.0133915  0.0124475
phi.9.2  -0.587335 0.26497 0.0083792  0.0090293
phi.9.3   0.085117 0.37280 0.0117891  0.0134057
phi.10.2 -0.996298 0.39233 0.0124066  0.0128439
phi.10.3 -0.392418 0.38979 0.0123263  0.0138242


--
View this message in context: 
http://r.789695.n4.nabble.com/Saving-summary-outputs-in-a-table-form-tp3381959p3381959.html
Sent from the R help mailing list archive at Nabble.com.

__
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] Saving summary outputs in a table form

2011-03-16 Thread Haillie
Thank you very much! I will check out help page for extraction operator.

Many thanks,
Haillie 

--
View this message in context: 
http://r.789695.n4.nabble.com/Saving-summary-outputs-in-a-table-form-tp3381959p3383316.html
Sent from the R help mailing list archive at Nabble.com.

__
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] converting data.frame into a numeric ( integer) form

2011-04-17 Thread Haillie
Hi Everyone,

I am relatively new to R and would appreciate your help on this problem that
I encontered this morning.
When running an ordinal IRT model using Ratings package on R, I keep getting
this error message.

ord.out<-ordrating(UNORD, burnin = 1000, mcmc = 40,000, thin = 400, tune =
1, verbose = 1000, seed = NA)

Error in as.vector(as.integer(Y)) : 
  (list) object cannot be coerced to type 'integer'

UNORD is my data.frame and it is in the form of delimited CSV file without
either row or column name.
According to the help page on Ordinal ratings, Y should be "a Matrix of data
to be analyzed. Entries must be integers from 1; : : : ;C or NA where C is
the number of ordinal categories. Items are on the rows and subjects are on
the columns." I am confused because my data.frame only contains numerica
values of 1,2,3, and NA. I checked and my NAs were all numeric. 

Any help or advice you could provide on this issue would be greatly
appreciated. Thank you very much.
I would like to thank all the R experts navigating this forum in advance. 

Sincerely,
Haillie 

--
View this message in context: 
http://r.789695.n4.nabble.com/converting-data-frame-into-a-numeric-integer-form-tp3455811p3455811.html
Sent from the R help mailing list archive at Nabble.com.

__
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] error message while running IRT model

2011-04-17 Thread Haillie
I have been struggling with the same problem for the past few hours and am
desperately in need of some help. The code I am running is as follows:

## opening a data set on the desktop
setwd("C:/Users/haillie/Desktop")
UN2010<- read.csv("UN2010.csv",header=TRUE)

##calling libraries
library(reshape)
library(car)

## these are the variables I want to recode
colname <- names(UN2010)


## this applies the recode functionto all the variable I want to recode
UN2010[colname] <-
   lapply(UN2010[colname],
   function(x) recode(x, recodes = "8=NA",
   as.factor.result = FALSE, as.numeric.result = TRUE))
   

UN2010frame<-data.matrix(lapply(UN2010,as.numeric))

ord.out1<-ordrating(UN2010, beta.constraint=1, tune=.035,
ma=1, mb=-5, vinva=1, vinvb=0.05,
gamma.start=c(-300, 0, 1.5, 3.0, 4.5, 300),
thin=20, burnin=2, mcmc=10, verbose=1000)


##
However, when i try to run the above ordrating code, an error message comes
up " NA/NaN/Inf in foreign function call (arg 24)." Because I interpreted
this as that this model has no ability to perform na.omit, I did na.omit
myself using the code UN2010<-na.omit(UN2010). However, I encoutered another
problem then. 

I recieved the below error messages this time..
Error in dimnames(x) <- dn : 
  length of 'dimnames' [1] not equal to array extent
In addition: Warning messages:
1: In min(Y, na.rm = TRUE) :
  no non-missing arguments to min; returning Inf
2: In max(Y, na.rm = TRUE) :
  no non-missing arguments to max; returning -Inf
3: In max(Y, na.rm = TRUE) :
  no non-missing arguments to max; returning -Inf
> 
##

I have tried everything I could but nothing has worked so far. Any advice or
help would be deeply appreciated. Thank you very much.

Haillie 


--
View this message in context: 
http://r.789695.n4.nabble.com/error-message-while-running-IRT-model-tp3456603p3456603.html
Sent from the R help mailing list archive at Nabble.com.
[[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] Unlist command drops all my column names in the first row and adopts NAs

2011-04-20 Thread Haillie
Hi Everyone, 

I am having trouble turning my data.frame into a matrix format. Because I
wanted to change my data.frame with mostly factor variables into a numeric
matrix, I used the following code -->
UN2010frame<-data.matrix(lapply(UN2010,as.numeric))

However when i checked the mode of the UN2010frame, it still showed up as a
list. Because the code I want to run (Ordrating) does not accept data in a
list format, I used UN2010matrix <- unlist(UN2010frame) to unlist my matrix.
When I did this, my first row ( which was formerly a row with column names)
turned into NAs. This was a problem for me because when I tried to run an
ordinal IRT model using this data set, I got the following error message. 

Error in 1:nrow(Y) : argument of length 0

I think it is because all the values in my first row are now gone 

If you could help me on any front, It would be deeply appreciated. Thank you
very much!

Haillie 


--
View this message in context: 
http://r.789695.n4.nabble.com/Unlist-command-drops-all-my-column-names-in-the-first-row-and-adopts-NAs-tp3463294p3463294.html
Sent from the R help mailing list archive at Nabble.com.

__
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] MCMCfactanal inquiries

2012-06-15 Thread Haillie Lee
Dear list,

Hi, I am emailing to see if it would be possible to get some help on
running MCMCfactanal on R. I am trying to derive a single score measuring a
likelihood to recieve IMF loans from 8 different variables related to IMF
representation but for reason, my codes do not seem to take me to where I
want to be. For some reason my code drops certain rows ( countries)
automatically, making it impossible for me to acquires factor scores for
those observations. It would also be great if you could let me know if
MCMCfactanal is the program to use for my purposes and recommend me better
functions or codes if possible.
Thank you very much in advance and I look forward to any help.

Sincerely,
Haillie

I am pasting the codes I have used below.

# installing packages
install.packages("MCMCpack")
install.packages("foreign")
install.packages("reshape")
install.packages("car")

## calling libraries
library(MCMCpack)
library(foreign)

### this loads TeachingDemos pkg and allows me to save txts
library(TeachingDemos)
txtStart("imfproject7.txt",commands = TRUE, results = TRUE, append = FALSE)

## calling libraries
library(MCMCpack)
library(foreign)

## opening a data set on the desktop
setwd("C:/Users/haillie/Desktop")
imfdata<- read.csv("imfdata.csv")

##calling libraries
library(reshape)
library(car)


## factanal Code ( 1 dimension with continuous variable)
postimfdata<-MCMCfactanal(~shstaff+shquota+frusanew+trshusnew+frdfgnew+trsheunew+usbanksh+eubanksh,
factors=1, data=imfdata, burnin=2, mcmc=20, thin=100, verbose=1000,
seed = NA, lambda.start = NA, psi.start = NA, l0 = 0, L0 = 0, a0 = 0.001,
b0 = 0.001, store.lambda = FALSE, store.scores = TRUE, std.var = TRUE)

Sincerely,
Haillie

[[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.