[R] legend position in barplot

2011-03-20 Thread Hongwei Dong
Hi, R users, I there a way that I can control the position of the legend while using barplot function? For example: a-matrix(c(0,0,0.5,0.8,0.9,0.9),2,3) colnames(a)-c(X,Y,Z) rownames(a)-c(A,B) a barplot(a,width = 0.2,legend = TRUE,axes=FALSE,col=c(coral3,steelblue3),beside=TRUE) In this case,

[R] identify an element in a column

2011-02-22 Thread Hongwei Dong
Hi, R users, I'm wondering if I can identify an element in a column by an element in another column. For example: x-1:10 y-11:20 z-cbind(x,y) z x y [1,] 1 11 [2,] 2 12 [3,] 3 13 [4,] 4 14 [5,] 5 15 [6,] 6 16 [7,] 7 17 [8,] 8 18 [9,] 9 19 [10,] 10 20 What I want to do is:

[R] aggregate in R

2011-02-22 Thread Hongwei Dong
Hi, R users, I'm wondering how I can aggregate data in R with different functions for different columns. For example: x-rep(1:5,3) y-cbind(x,a=1:15,b=21:35) y-data.frame(y) I want to aggregate a and b in y by x. With a, I want to use function mean; with b, I want to use function sum. I tried:

[R] Sample function in R???

2011-02-19 Thread Hongwei Dong
Hi, R users, I'm wondering if there a way in R I can select cases based on a probability vector. if a case is selected, that case is marked as 1, otherwise, 0. For example: x-12:18 y-1:7 sample(x,2,replace=FALSE,y) I got: [1] 15 17 What I want to see is: [1] 0 0 0 1 0 1 0 Thanks. Gary

[R] use summary

2011-02-03 Thread Hongwei Dong
Hi, dear R users, I'm running a Tobit regression and using summary to display model results. It used to work. But this time, I kept getting this: summary(RES_TOBIT) Length Class Mode 1 vglm S4 Could anyone tell me how to solve this problem, and why I got this problem? Thanks.

[R] Maxiter specification in R

2011-01-21 Thread Hongwei Dong
Dear R users, I'm having a problem with maxiter specification in VGLM function. I tried to increase the number of iteration to 100, but it still stopped at 30, which is the default. Here is my script: FIT - vglm(SFH_PCT ~ RD_DEN + CAR_HH + TRS + RES_L, tobit(Lower=0), maxiter = 100) Thanks

[R] number of iterations in a Tobit model

2011-01-20 Thread Hongwei Dong
Hi, R users, I'm running a Tobit model but convergence can not be reached within 30 iterations. Is there anyway I can change the max number of iterations? Thanks. Gary [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

[R] reduce the size of points in plot???

2010-10-16 Thread Hongwei Dong
Hi, R users, Can anyone tell me how I can change the size of points in my plot? For example: x - c(1,3,6,9,12) y - c(1.5,2,7,8,15) plot(x,y,pch=20) How do I reduce the size of those points? Thanks. Gary [[alternative HTML version deleted]]

[R] how to change the font size of x and y axis labels?

2010-10-06 Thread Hongwei Dong
Dear R users, Anyone can tell me how to change the font size of X and Y axis labels in plot function? Thanks. Gary [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE

[R] Monte Carlo simulation in R

2010-03-23 Thread Hongwei Dong
Hi, R-helpers, I'm trying to use R to do a Monte Carlo simulation and need the help. What I have is a matrix that consists of the probabilities for the persons to choose zones. For example, in the matrix shown below, each column represents a person, and each row represents a zone. So, the

[R] with data in the form of an R data objecte: Monte Carlo simulation in R

2010-03-23 Thread Hongwei Dong
Hi, please use the following the matrix z as the example: x-c(2,4,5,7,6,9,8,2,0) y-matrix(x,3,3) z-apply(y,2,function(x)x/sum(x)) z On Tue, Mar 23, 2010 at 6:59 PM, David Winsemius dwinsem...@comcast.netwrote: On Mar 23, 2010, at 9:05 PM, Hongwei Dong wrote: Hi, R-helpers, I'm trying

[R] set condition in R

2009-11-26 Thread Hongwei Dong
Hi, R users, I'm using while() in R to set a condition. My condition is: i523 or i535. How should I write this in R? I try while (i523 or i535) and it does not work. Thanks. Garry On Tue, Nov 10, 2009 at 11:26 AM, Hongwei Dong pdxd...@gmail.com wrote: Exactly! Thanks, Duncan. Let me re

[R] Monte Carlo Simulation in R...

2009-11-10 Thread Hongwei Dong
Hi, Dear R users, I'm wondering if I can do Monte Carlo Simulation in R. My problem is like this: I know variable X follows Gamma distribution with shape parameter 0.067 and scale parameter 0.008. The sum of the X is 2000. I need R help me to simulate a vector of X that satisfies both the

[R] Generate Random Draw from Gamma Distribution Re: Monte Carlo Simulation in R...

2009-11-10 Thread Hongwei Dong
to generate random draw. I'm wondering how I can do this in R. Thanks. Garry On Tue, Nov 10, 2009 at 11:17 AM, Duncan Murdoch murd...@stats.uwo.cawrote: On 11/10/2009 1:25 PM, Hongwei Dong wrote: Hi, Dear R users, I'm wondering if I can do Monte Carlo Simulation in R. My problem is like

Re: [R] Generate Random Draw from Gamma Distribution Re: Monte Carlo Simulation in R...

2009-11-10 Thread Hongwei Dong
, Hongwei Dong wrote: Exactly! Thanks, Duncan. Let me re-phrase me question like this: 1) X_i values are independent Gammas, with the shape 0.067 and scale 0.008 2) Min(X)=1 and Max(X)=85 You might want to check that your parameterization in in agreement with that used by the rgamma function

Re: [R] Generate Random Draw from Gamma Distribution Re: Monte Carlo Simulation in R...

2009-11-10 Thread Hongwei Dong
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of David Winsemius Sent: Tuesday, November 10, 2009 2:47 PM To: Hongwei Dong Cc: R-help Forum; Duncan Murdoch Subject: Re: [R] Generate Random Draw

Re: [R] Generate Random Draw from Gamma Distribution Re: Monte Carlo Simulation in R...

2009-11-10 Thread Hongwei Dong
By the way, maybe the number of groups can be determined endogenously. It will be better if I do not have to set the total number of groups exogenously. Thanks Garry On Tue, Nov 10, 2009 at 1:29 PM, Hongwei Dong pdxd...@gmail.com wrote: Sorry for the confusion. Let me put it in this way

[R] How to transform the Matrix into the way I want it ???

2009-11-09 Thread Hongwei Dong
Hi, R users, I'm trying to transform a matrix A into B (see below). Anyone knows how to do it in R? Thanks. Matrix A (zone to zone travel time) zone z1 z2 z3 z1 0 2.9 4.3 z2 2.9 0 2.5 z3 4.3 2.5 0 B: from to time z1 z1 0 z1 z2 2.9 z1 z3 4.3 z2 z1 2.9 z2 z2 0 z2 z3 2.5 z3 z1 4.3 z3 z2 2.5

[R] memory limit in R

2009-08-18 Thread Hongwei Dong
Hi, all, I'm doing a discrete choice model in R and kept getting this error: Error: cannot allocate vector of size 198.6 Mb. Does this mean the memory limit in R has been reached? memory.size() [1] 1326.89 memory.size(TRUE) [1] 1336 memory.limit() [1] 1535 My laptop has a 4G memory with

Re: [R] memory limit in R

2009-08-18 Thread Hongwei Dong
The size of my .Rdata workspace is about 9.2 M and the data I'm using is the only one object in this workspace. Is it a large one? Thanks. Harry On Tue, Aug 18, 2009 at 4:21 AM, jim holtman jholt...@gmail.com wrote: About 2GB is the limit of the address space on 32-bit windows (you can get

Re: [R] why summary() does not work here???

2009-08-16 Thread Hongwei Dong
. 2009/8/16 Hongwei Dong pdxd...@gmail.com: Hi, R users, I'm using the function vglm to estimate a multinomial logit model. Every time I use summary() to ask for the coefficients and std error, I got this: Length Class Mode 1 vglm S4 Anyone know what's wrong here

Re: [R] why summary() does not work here???

2009-08-16 Thread Hongwei Dong
, Gavin Simpson gavin.simp...@ucl.ac.ukwrote: On Sun, 2009-08-16 at 10:48 -0700, Hongwei Dong wrote: I'm quite sure the VGAM package has been installed because I used it to estimate the model before I use summary(). One reason I can guess is that the default method for summary() is S3

Re: [R] Estimate Discrete Choice Models with R

2009-08-15 Thread Hongwei Dong
? Thanks. Harry On Fri, Aug 14, 2009 at 3:49 PM, Hongwei Dong pdxd...@gmail.com wrote: Hi, R users, Does anyone know whether there are any Discrete Choice Modeling modules for R? Any books or websites discussing this? Thanks Harry [[alternative HTML version deleted

[R] why summary() does not work here???

2009-08-15 Thread Hongwei Dong
Hi, R users, I'm using the function vglm to estimate a multinomial logit model. Every time I use summary() to ask for the coefficients and std error, I got this: Length Class Mode 1 vglm S4 Anyone know what's wrong here? Thanks. Harry [[alternative HTML version

[R] Estimate Discrete Choice Models with R

2009-08-14 Thread Hongwei Dong
Hi, R users, Does anyone know whether there are any Discrete Choice Modeling modules for R? Any books or websites discussing this? Thanks Harry [[alternative HTML version deleted]] __ R-help@r-project.org mailing list

Re: [R] lme funcion in R

2009-08-05 Thread Hongwei Dong
-boun...@r-project.org] Namens Hongwei Dong Verzonden: woensdag 5 augustus 2009 1:49 Aan: r-help@r-project.org Onderwerp: Re: [R] lme funcion in R Yeah, I have a very large sample size, about 60,000 observations. Multicollinearity should not be a problem here. The weird thing is that SPSS can

Re: [R] lme funcion in R

2009-08-04 Thread Hongwei Dong
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 -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Hongwei Dong Verzonden

Re: [R] lme funcion in R

2009-08-04 Thread Hongwei Dong
On Tue, Aug 4, 2009 at 5:47 PM, David Winsemius dwinsem...@comcast.netwrote: On Aug 4, 2009, at 7:48 PM, Hongwei Dong wrote: Yeah, I have a very large sample size, about 60,000 observations. Multicollinearity should not be a problem here. The weird thing is that SPSS can converge very

Re: [R] lme funcion in R

2009-08-04 Thread Hongwei Dong
In addition, it seems the lme function in R are very troubled with the dummy variables used at the first (random) level. Harry On Tue, Aug 4, 2009 at 6:06 PM, Hongwei Dong pdxd...@gmail.com wrote: Thanks, David, you are right. If I use continuous data such as 1, 2, ...6 to represent those 6

Re: [R] lme funcion in R

2009-08-04 Thread Hongwei Dong
...@comcast.netwrote: On Aug 4, 2009, at 9:06 PM, Hongwei Dong wrote: Thanks, David, you are right. If I use continuous data such as 1, 2, ...6 to represent those 6 housing types, the model works with the lme function in R. The problem is, the relationship between the 6 housing types are not continuous, which

Re: [R] principal component analysis for class variables

2009-08-03 Thread Hongwei Dong
Hi, R users, I'm using the lme function in R to estimate a 2 level mixed effects model, in which the size of the groups are different. It turned out that It takes forever for R to converge. I also tried the same thing in SPSS and SPSS can give the results out within 20 minutes. Anyone can give

[R] lme funcion in R

2009-08-03 Thread Hongwei Dong
Hi, R users, I'm using the lme function in R to estimate a 2 level mixed effects model, in which the size of the subject groups are different. It turned out that It takes forever for R to converge. I also tried the same thing in SPSS and SPSS can give the results out within 20 minutes. Anyone

Re: [R] lme funcion in R

2009-08-03 Thread Hongwei Dong
0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 ... $ transit_D : num 0 0 0 0 0 0 0 0 0 0 ... $ park_dum : num 0 0 0 0 0 0 0 0 0 0 ... Thanks. Harry On Mon, Aug 3, 2009 at 10:36 AM, Jason Morgan jwm-r-h...@skepsi.net wrote: On 2009.08.03 10:15:46, Hongwei Dong wrote: Hi, R users, I'm using

[R] What does this error message mean?

2009-08-03 Thread Hongwei Dong
Hi, I used R to run a linear regression and keep getting the following error message. I do not understand it very well. Anyone can help out? Thanks. Error in storage.mode(y) - double : invalid to change the storage mode of a factor In addition: Warning message: In model.response(mf, numeric) :

Re: [R] lme funcion in R

2009-08-03 Thread Hongwei Dong
, Hongwei Dong wrote: Hi, R users, I'm using the lme function in R to estimate a 2 level mixed effects model, in which the size of the subject groups are different. It turned out that It takes forever for R to converge. I also tried the same thing in SPSS and SPSS can give the results out

Re: [R] how to predict dynamic model in R

2009-07-23 Thread Hongwei Dong
Hi, Gabor and Other R users, I'm re-posting my script and the results I got. here is the dynamic model I used to estimate in-sample model (1996-2006) and it works: fit-dyn$lm(Y~lag(Y,-1)+z+x+lag(x,-1)+lag(x,-2)+lag(x,-3)+lag(x,-4)) Then I used this model to do out sample forecast with

Re: [R] how to predict dynamic model in R

2009-07-23 Thread Hongwei Dong
Hi, Gabor, got it. Thanks a lot. I have one more question about how the predict function works here, especially for the lag(Y,-1) part. In my model, I assume I know predictors x and z in the next two years, and use them to predict Y. For each forecast step at time t, the lag(Y,-1) in the model

Re: [R] how to predict dynamic model in R

2009-07-23 Thread Hongwei Dong
Thanks, Gabor. Here are the problems I'm trying to solve. *FIRST*, I run this to simulate a 20 years time series process. The data from 1-15 years are used to estimate the model, and this model is used to predict the year from 16-20. The following script works. set.seed(123) tt - ts(cbind(Y =

Re: [R] how to predict dynamic model in R

2009-07-23 Thread Hongwei Dong
What I want R to do is to use the estimated Y at t-1 to be the lag(Y,-1) in the forecast equation for time t. Is there anyway I can realize this with R? For example, when the Y value for year 18 is forecast, the estimated Y for year 17 is used, not the actual Y for year 17 already in the data.

Re: [R] how to predict dynamic model in R

2009-07-23 Thread Hongwei Dong
Hi, Gabor, it seems ARIMA model does not have that problem. For example: set.seed(123) y-ts(c(1:20)) x = ts(rnorm(20)) z = ts(rnorm(20)) tt-ts(cbind(x, lag(x,-1),lag(x,-2),z)) fit - arima(y[1:15],order=c(1,0,0),xreg=tt[(1:15),]) fit pred - predict(fit, n.ahead=5,tt[(16:20),]) pred What do you

[R] how to predict dynamic model in R

2009-07-22 Thread Hongwei Dong
I have a dynamic time series model like this: dyn$lm( y ~ lag(y,-1) + x + lag(x,-1)+lag(x,-2) ) I need to do an out of sample forecast with this model. Is there any way I can do this with R? It would be greatly appreciated if some one can give me an example. Thanks. Harry [[alternative

[R] Plot two graphs with different ranges in one

2009-07-02 Thread Hongwei Dong
Hi, I'm trying to plot two variables in one graph. One ranges between 0 and 1, while the other ranges between 50 and 500. Can I plot them in one graph with similar scale? Thanks Harry [[alternative HTML version deleted]] __

[R] How to use subset in lm function

2009-06-29 Thread Hongwei Dong
Hi, I'm using R to do a time series analysis. In the model, I use the lags of some variables. such the lags of the variables have different length, I just can't use them directly in the lm function. Intuitively, I feel that subset might be useful, but I do not know how to use it. Anyone can give

[R] select number of lags in ADF.test

2009-06-25 Thread Hongwei Dong
Hi, all, According to the ADF.test help,Singf removes the non-significant lags at the 10% level of significance until all the selected lags are significant. However, when I use singf, it still give me the lags that are not significant at 10% level. Anyone knows why? Thanks. Harry