[R] problems with garchFit

2006-11-22 Thread T Mu
Hi all,

I post it on both r-help and r-finance since I don't know where is most
appropriate for this topic. Sorry if it bothers you.

I did garch fitting on SP500 monthly returns with garchFit from fSeries. I
got same coefficients from all cond.dist except normal. I thought that is
probabaly usual for the data. But when I play with it, I got another
question.

I plot skew normal with skew = 1 and a standard normal, they overlap
eachother, so I think they are the same. Skew = 1 means no skewness (I can
not find the paper defining the distribution).

library(fSeries)
curve(dsnorm(x, 0, 1, 1), -2, 2, add = F, col = 'red') #skew normal with
skew 1
curve(dnorm(x, 0, 1), -2, 2, add = T, col = 'blue') #normal

Then I try them as innovations,

#normal innovation
garch_norm - garchFit(series = logr, include.mean = F)

#skew normal innovation

#this line do not include skew, so it got same result as normal
garch_snorm - garchFit(series = logr, cond.dist = 'dsnorm', include.mean =
F, include.skew = F)

#this line includes skew, but use default skew = 1, and it got results
different from normal, which I don't understand

garch_snorm - garchFit(series = logr, cond.dist = 'dsnorm', include.mean =
F, include.skew = T)

Have I done something wrong? I am attaching the code, thank you.

Tian

#GARCH analysis of monthly return
rm(list=ls(all=TRUE))
sp500 - read.csv('sp_m90.csv', header=TRUE)
sp500 - sp500[,2] #only adjusted close
n - length(sp500)

logr - log(sp500[1:n-1] / sp500[2:n])
acf(logr)
ar5 - arima(logr, order = c(5, 0, 0), include.mean = T)
logr- ar5$res
acf(logr)

#fit GARCH distribution
hist(logr, freq = F, ylim = c(0, 12), breaks = 'FD')

norm_fit - normFit(logr)
curve(dnorm(x, norm_fit$est[1], norm_fit$est[2]), -.15, .15, add = TRUE,
col=2)

t_fit - stdFit(logr)
curve(dstd(x, t_fit$est[1], t_fit$est[2], t_fit$est[3]), -.15, .15, add =
TRUE, col=6)

snorm_fit - snormFit(logr)
curve(dsnorm(x, snorm_fit$est[1], snorm_fit$est[2], snorm_fit$est[3]), -.25,
.15, add = TRUE, col=4)

st_fit - sstdFit(logr)
curve(dsstd(x, st_fit$est[1], st_fit$est[2], st_fit$est[3], st_fit$est[4]),
-.25, .15, add = TRUE, col=3)

library(fSeries)

#normal innovation
garch_norm - garchFit(series = logr, include.mean = F)

#t inovation
garch_t - garchFit(series = logr, cond.dist = 'dstd', include.mean = F,
include.shape = T)
garch_t1 - garchFit(series = logr, cond.dist = 'dstd', include.mean = F,
shape = t_fit$est[3], include.shape = T)

#skew normal innovation
garch_snorm - garchFit(series = logr, cond.dist = 'dsnorm', include.mean =
F, include.skew = T)
garch_snorm1 - garchFit(series = logr, cond.dist = 'dsnorm', include.mean =
F, skew = snorm_fit$est[3], include.skew = T)

#skew t innovation
garch_st - garchFit(series = logr, cond.dist = 'dsstd', include.mean = F,
include.skew = T, include.shape = T)
garch_st1 - garchFit(series = logr, cond.dist = 'dsstd', include.mean = F,
skew = st_fit$est[4], shape = st_fit$est[3], include.skew = T, include.shape= T)

vix - read.csv('D:/Documents and Settings/Mu Tian/Desktop/8780/8780
project/vix_m.csv', header=TRUE)
vix - (vix[,2]/100) / (12^.5)

plot_sd - function(x, ylim = null, col = null, ...) {
xcsd = [EMAIL PROTECTED]
plot(xcsd, type = l, col = col, ylab = x,
main = Conditional SD, ylim = ylim)
abline(h = 0, col = grey, lty = 3)
grid()
}

plot_sd(garch_norm, ylim = c(0.02, 0.13), col = 2)
xcsd = [EMAIL PROTECTED]
lines(xcsd, col = 3)
lines(1:n, vix)

#predict
predict(garch_norm)
predict(garch_t)

#demonstration of skew distributions
#skew normal
curve(dsnorm(x, 0, 1, .1), -2, 2, add = F, col = 'green')
curve(dsnorm(x, 0, 1, snorm_fit$est[3]), type = 'l', col = 'blue', add = T)
curve(dsnorm(x, 0, 1, 1), -2, 2, add = T, col = 'red') #normal

#skew t
curve(dsstd(x, 0, 1, 4, 1), -2, 2, add = F, col = 'red')
curve(dsstd(x, 0, 1, st_fit$est[3], st_fit$est[4]), type = 'l', col =
'blue', add = T)
curve(dsstd(x, 0, 1, 100, .5), -2, 2, add = T, col = 'green')

#t
curve(dstd(x, 0, 1, 4), -2, 2, add = T, col = 'red')
curve(dstd(x, 0, 1, t_fit$est[3]), type = 'l', col = 'blue', add = T)
curve(dstd(x, 0, 1, 100), -2, 2, add = T, col = 'green')

curve(dsnorm(x, 0, 1, 1), -2, 2, add = F, col = 'red') #normal
curve(dnorm(x, 0, 1), -2, 2, add = T, col = 'blue') #normal
curve(dsnorm(x, 0, 1, .1), -2, 2, add = T, col = 'green') #normal

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] problems with garchFit

2006-11-22 Thread T Mu
Hi all,

Thank you for responses. If any one need the data, I can email it to you. I
don't think I can attach it to R-help. It is only SP 500 monthly returns I
downloaded from Yahoo finance, with only date and adj. close kept.

Thank you,

Tian


On 11/22/06, T Mu [EMAIL PROTECTED] wrote:

 Hi all,

 I post it on both r-help and r-finance since I don't know where is most
 appropriate for this topic. Sorry if it bothers you.

 I did garch fitting on SP500 monthly returns with garchFit from fSeries.
 I got same coefficients from all cond.dist except normal. I thought that
 is probabaly usual for the data. But when I play with it, I got another
 question.

 I plot skew normal with skew = 1 and a standard normal, they overlap
 eachother, so I think they are the same. Skew = 1 means no skewness (I can
 not find the paper defining the distribution).

 library(fSeries)
 curve(dsnorm(x, 0, 1, 1), -2, 2, add = F, col = 'red') #skew normal with
 skew 1
 curve(dnorm(x, 0, 1), -2, 2, add = T, col = 'blue') #normal

 Then I try them as innovations,

 #normal innovation
 garch_norm - garchFit(series = logr, include.mean = F)

 #skew normal innovation

 #this line do not include skew, so it got same result as normal
 garch_snorm - garchFit(series = logr, cond.dist = 'dsnorm', include.mean= F,
 include.skew = F)

 #this line includes skew, but use default skew = 1, and it got results
 different from normal, which I don't understand

 garch_snorm - garchFit(series = logr, cond.dist = 'dsnorm', include.mean= F,
 include.skew = T)

 Have I done something wrong? I am attaching the code, thank you.

 Tian

 #GARCH analysis of monthly return
 rm(list=ls(all=TRUE))
 sp500 - read.csv('sp_m90.csv', header=TRUE)
 sp500 - sp500[,2] #only adjusted close
 n - length(sp500)

 logr - log(sp500[1:n-1] / sp500[2:n])
 acf(logr)
 ar5 - arima(logr, order = c(5, 0, 0), include.mean = T)
 logr- ar5$res
 acf(logr)

 #fit GARCH distribution
 hist(logr, freq = F, ylim = c(0, 12), breaks = 'FD')

 norm_fit - normFit(logr)
 curve(dnorm(x, norm_fit$est[1], norm_fit$est[2]), -.15, .15, add = TRUE,
 col=2)

 t_fit - stdFit(logr)
 curve(dstd(x, t_fit$est[1], t_fit$est[2], t_fit$est[3]), -.15, .15, add =
 TRUE, col=6)

 snorm_fit - snormFit(logr)
 curve(dsnorm(x, snorm_fit$est[1], snorm_fit$est[2], snorm_fit$est[3]),
 -.25, .15, add = TRUE, col=4)

 st_fit - sstdFit(logr)
 curve(dsstd(x, st_fit$est[1], st_fit$est[2], st_fit$est[3],
 st_fit$est[4]), -.25, .15, add = TRUE, col=3)

 library(fSeries)

 #normal innovation
 garch_norm - garchFit(series = logr, include.mean = F)

 #t inovation
 garch_t - garchFit(series = logr, cond.dist = 'dstd', include.mean = F,
 include.shape = T)
 garch_t1 - garchFit(series = logr, cond.dist = 'dstd', include.mean = F,
 shape = t_fit$est[3], include.shape = T)

 #skew normal innovation
 garch_snorm - garchFit(series = logr, cond.dist = 'dsnorm', include.mean= F,
 include.skew = T)
 garch_snorm1 - garchFit(series = logr, cond.dist = 'dsnorm', include.mean= 
 F, skew = snorm_fit$est[3],
 include.skew = T)

 #skew t innovation
 garch_st - garchFit(series = logr, cond.dist = 'dsstd', include.mean = F,
 include.skew = T, include.shape = T)
 garch_st1 - garchFit(series = logr, cond.dist = 'dsstd', include.mean =
 F, skew = st_fit$est[4], shape = st_fit$est[3], include.skew = T,
 include.shape = T)

 vix - read.csv('D:/Documents and Settings/Mu Tian/Desktop/8780/8780
 project/vix_m.csv', header=TRUE)
 vix - (vix[,2]/100) / (12^.5)

 plot_sd - function(x, ylim = null, col = null, ...) {
 xcsd = [EMAIL PROTECTED]
 plot(xcsd, type = l, col = col, ylab = x,
 main = Conditional SD, ylim = ylim)
 abline(h = 0, col = grey, lty = 3)
 grid()
 }

 plot_sd(garch_norm, ylim = c(0.02, 0.13), col = 2)
 xcsd = [EMAIL PROTECTED]
 lines(xcsd, col = 3)
 lines(1:n, vix)

 #predict
 predict(garch_norm)
 predict(garch_t)

 #demonstration of skew distributions
 #skew normal
 curve(dsnorm(x, 0, 1, .1), -2, 2, add = F, col = 'green')
 curve(dsnorm(x, 0, 1, snorm_fit$est[3]), type = 'l', col = 'blue', add =
 T)
 curve(dsnorm(x, 0, 1, 1), -2, 2, add = T, col = 'red') #normal

 #skew t
 curve(dsstd(x, 0, 1, 4, 1), -2, 2, add = F, col = 'red')
 curve(dsstd(x, 0, 1, st_fit$est[3], st_fit$est[4]), type = 'l', col =
 'blue', add = T)
 curve(dsstd(x, 0, 1, 100, .5), -2, 2, add = T, col = 'green')

 #t
 curve(dstd(x, 0, 1, 4), -2, 2, add = T, col = 'red')
 curve(dstd(x, 0, 1, t_fit$est[3]), type = 'l', col = 'blue', add = T)
 curve(dstd(x, 0, 1, 100), -2, 2, add = T, col = 'green')

 curve(dsnorm(x, 0, 1, 1), -2, 2, add = F, col = 'red') #normal
 curve(dnorm(x, 0, 1), -2, 2, add = T, col = 'blue') #normal
 curve(dsnorm(x, 0, 1, .1), -2, 2, add = T, col = 'green') #normal


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting

Re: [R] problems with garchFit

2006-11-22 Thread T Mu
], st_fit$est[3], st_fit$est[4]),
-.25, .15, add = TRUE, col=3)

legend('topleft', '---Normal', text.col = 'red', bty = 'n')
legend('topleft', '---Student t', text.col = 6, bty = 'n', inset = c(0,
.05))
legend('topleft', '---Skew Normal', text.col = 'blue', bty = 'n', inset =
c(0, .1))
legend('topleft', '---Skew t', text.col = 'green', bty = 'n', inset = c(0,
.15))

library(fSeries)

#normal innovation
garch_norm - garchFit(series = logr, include.mean = F)

#skew normal innovation
garch_snorm1 - garchFit(series = logr, cond.dist = 'dsnorm', include.mean =
F, skew = snorm_fit$est[3], include.skew = T)

#t inovation
garch_t - garchFit(series = logr, cond.dist = 'dstd', include.mean = F,
include.shape = T)
garch_t1 - garchFit(series = logr, cond.dist = 'dstd', include.mean = F,
shape = t_fit$est[3], include.shape = T)

#skew t innovation
garch_st - garchFit(series = logr, cond.dist = 'dsstd', include.mean = F,
include.skew = T, include.shape = T)
garch_st1 - garchFit(series = logr, cond.dist = 'dsstd', include.mean = F,
skew = st_fit$est[4], shape = st_fit$est[3], include.skew = T, include.shape= T)
garch_st2 - garchFit(series = logr, cond.dist = 'dsstd', include.mean = F,
skew = st_fit$est[4], shape = st_fit$est[3], include.skew = F, include.shape= F)
garch_st3 - garchFit(series = logr, cond.dist = 'dsstd', include.mean = F,
skew = st_fit$est[4], shape = st_fit$est[3])
garch_st4 - garchFit(series = logr, cond.dist = 'dsstd', include.mean = F)

plot_sd - function(x, ylim = null, col = null, ...) {
xcsd = [EMAIL PROTECTED]
plot(xcsd, type = l, col = col, ylab = x,
main = Conditional SD, ylim = ylim)
abline(h = 0, col = grey, lty = 3)
grid()
}

plot_sd(garch_norm, ylim = c(0.02, 0.13), col = 2)
xcsd = [EMAIL PROTECTED]
lines(xcsd, col = 3)

legend('topleft', '---Normal innovation', text.col = 'red', bty = 'n', inset
= c(0, .05))
legend('topleft', '---Skew innovation', text.col = 'green', bty = 'n', inset
= c(0, .1))

On 11/22/06, Gabor Grothendieck [EMAIL PROTECTED] wrote:

 As a courtesy to others you might summarize the responses to the list.
 Also,
 I suggest you also include the data by issuing the command:

   dput(x, control = all) # x is your data

 and pasting its result into your post so others can reproduce
 what you have done.

 On 11/22/06, T Mu [EMAIL PROTECTED]  wrote:
  Hi all,
 
  Thank you for responses. If any one need the data, I can email it to
 you. I
  don't think I can attach it to R-help. It is only SP 500 monthly
 returns I
  downloaded from Yahoo finance, with only date and adj. close kept.
 
  Thank you,
 
  Tian
 
 
  On 11/22/06, T Mu [EMAIL PROTECTED] wrote:
  
   Hi all,
  
   I post it on both r-help and r-finance since I don't know where is
 most
   appropriate for this topic. Sorry if it bothers you.
  
   I did garch fitting on SP500 monthly returns with garchFit from
 fSeries.
   I got same coefficients from all cond.dist except normal. I thought
 that
   is probabaly usual for the data. But when I play with it, I got
 another
   question.
  
   I plot skew normal with skew = 1 and a standard normal, they overlap
   eachother, so I think they are the same. Skew = 1 means no skewness (I
 can
   not find the paper defining the distribution).
  
   library(fSeries)
   curve(dsnorm(x, 0, 1, 1), -2, 2, add = F, col = 'red') #skew normal
 with
   skew 1
   curve(dnorm(x, 0, 1), -2, 2, add = T, col = 'blue') #normal
  
   Then I try them as innovations,
  
   #normal innovation
   garch_norm - garchFit(series = logr, include.mean = F)
  
   #skew normal innovation
  
   #this line do not include skew, so it got same result as normal
   garch_snorm - garchFit(series = logr, cond.dist = 'dsnorm',
 include.mean= F,
   include.skew = F)
  
   #this line includes skew, but use default skew = 1, and it got results
   different from normal, which I don't understand
  
   garch_snorm - garchFit(series = logr, cond.dist = 'dsnorm',
 include.mean= F,
   include.skew = T)
  
   Have I done something wrong? I am attaching the code, thank you.
  
   Tian
  
   #GARCH analysis of monthly return
   rm(list=ls(all=TRUE))
   sp500 - read.csv('sp_m90.csv', header=TRUE)
   sp500 - sp500[,2] #only adjusted close
   n - length(sp500)
  
   logr - log(sp500[1:n-1] / sp500[2:n])
   acf(logr)
   ar5 - arima(logr, order = c(5, 0, 0), include.mean = T)
   logr- ar5$res
   acf(logr)
  
   #fit GARCH distribution
   hist(logr, freq = F, ylim = c(0, 12), breaks = 'FD')
  
   norm_fit - normFit(logr)
   curve(dnorm(x, norm_fit$est[1], norm_fit$est[2]), -.15, .15, add =
 TRUE,
   col=2)
  
   t_fit - stdFit(logr)
   curve(dstd(x, t_fit$est[1], t_fit$est[2], t_fit$est[3]), -.15, .15,
 add =
   TRUE, col=6)
  
   snorm_fit - snormFit(logr)
   curve(dsnorm(x, snorm_fit$est[1], snorm_fit$est[2], snorm_fit$est[3]),
   -.25, .15, add = TRUE, col=4)
  
   st_fit - sstdFit(logr)
   curve(dsstd(x, st_fit$est[1], st_fit$est[2], st_fit$est[3],
   st_fit$est[4]), -.25, .15, add = TRUE

[R] questions about garchFit

2006-11-21 Thread T Mu
 Hi all,

I was trying garchFIt() of fSeries to fit volatility of monthly log returns
of SP500. I tried residuals of normal, student t, skew normal, skew t. But
all innovations except normal got exaxtly same coefficients, even if I
changed their parameters of skew and shape.

Is this correct for the data or something wrong? I am attaching the code,
thank you.

Muster

#GARCH analysis of monthly return
rm(list=ls(all=TRUE))
sp500 - read.csv('sp_m.csv', header=TRUE)
sp500 - sp500[,2] #only adjusted close
n - length(sp500)

logr - log(sp500[1:n-1] / sp500[2:n])
acf(logr)
ar5 - arima(logr, order = c(5, 0, 0), include.mean = T)
logr- ar5$res #remove mean
acf(logr)

#fit GARCH distribution
hist(logr, freq = F, ylim = c(0, 12), breaks = 'FD')

norm_fit - normFit(logr)
curve(dnorm(x, norm_fit$est[1], norm_fit$est[2]), -.15, .15, add = TRUE,
col=2)

t_fit - stdFit(logr)
curve(dstd(x, t_fit$est[1], t_fit$est[2], t_fit$est[3]), -.15, .15, add =
TRUE, col=6)

snorm_fit - snormFit(logr)
curve(dsnorm(x, snorm_fit$est[1], snorm_fit$est[2], snorm_fit$est[3]), -.25,
.15, add = TRUE, col=4)

st_fit - sstdFit(logr)
curve(dsstd(x, st_fit$est[1], st_fit$est[2], st_fit$est[3], st_fit$est[4]),
-.25, .15, add = TRUE, col=3)

library(fSeries)

#normal innovation
garch_norm - garchFit(series = logr, include.mean = F)

#t inovation
garch_t - garchFit(series = logr, cond.dist = 'dstd', include.mean = F,
include.shape = T)
garch_t1 - garchFit(series = logr, cond.dist = 'dstd', include.mean = F,
shape = t_fit$est[3], include.shape = T)

#skew normal innovation
garch_snorm - garchFit(series = logr, cond.dist = 'dsnorm', include.mean =
F, include.skew = T)
garch_snorm1 - garchFit(series = logr, cond.dist = 'dsnorm', include.mean =
F, skew = snorm_fit$est[3], include.skew = T)

#skew t innovation
garch_st - garchFit(series = logr, cond.dist = 'dsstd', include.mean = F,
include.skew = T, include.shape = T)
garch_st1 - garchFit(series = logr, cond.dist = 'dsstd', include.mean = F,
skew = st_fit$est[4], shape = st_fit$est[3], include.skew = T, include.shape= T)

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] R gui console problem

2006-09-24 Thread T Mu
Hi all,

My R GUI got a weird perk. It loads only first page of scripts, about 28
rows. I didn't change any configuration or installed anything special.

I use R 2.3.1, windows. Help please.

Thank you.

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] confusing about contrasts concept

2006-08-16 Thread T Mu
Hi all,

Where can I find a thorough explanation of Contrasts and Contrasts Matrices?
I read some help but still confused.

Thank you,
Tian

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] confusing about contrasts concept

2006-08-16 Thread T Mu
Thank you. Got both.

On 8/16/06, Peter Alspach [EMAIL PROTECTED] wrote:


 Tian

 Bill Venables wrote an excellent explanation to the S list back in 1997.
 I saved it as a pdf file and attach it herewith ...

 Peter Alspach


  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf Of T Mu
  Sent: Thursday, 17 August 2006 3:23 a.m.
  To: R-Help
  Subject: [R] confusing about contrasts concept
 
  Hi all,
 
  Where can I find a thorough explanation of Contrasts and
  Contrasts Matrices?
  I read some help but still confused.
 
  Thank you,
  Tian
 
[[alternative HTML version deleted]]
 
  __
  R-help@stat.math.ethz.ch 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.
 


 __

 The contents of this e-mail are privileged and/or confidential to the
 named recipient and are not to be used by any other person and/or
 organisation. If you have received this e-mail in error, please notify
 the sender and delete all material pertaining to this e-mail.
 __



[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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 contrasts for polr() to get same result of SAS

2006-08-16 Thread T Mu
Hi all,

I am trying to do a ordered probit regression using polr(), replicating a
result from SAS.

polr(y ~ x, dat, method='probit')

suppose the model is y ~ x, where y is a factor with 3 levels and x is a
factor with 5 levels,

To get coefficients, SAS by default use the last level as reference, R by
default use the first level (correct me if I was wrong),

The result I got is a mixture, using first and last for different variables.

I tried relevel, reorder, contrasts, but no success. I found what really
matters is

options(contrasts = c(contr.treatment, contr.poly))

or

options(contrasts = c(contr.SAS, contr.poly))

so I guess I can set contrasts= a list of contrasts for each variables in
polr(), but I cannot successfuly set the contrasts, what is the syntax?

Is there a better way to do this?

Thank you very much,
Tian

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] How to show classes of all columns of a data frame?

2006-08-15 Thread T Mu
Hi all,

Suppose I have a data frame myDF, col A is factor, col B is numeric, col C
is character. I can get their classes by

 class(myDF$A)

but is there a quick way to show what classes of all columns are? Thank you.

Tian

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] model = F causing error in polr()

2006-08-15 Thread T Mu
Hi all,

I got an error message if I set model =F in polr(), like

 polr(y ~ x1 + x2, data1, model = F, method = probit)

Error in model.frame(formula, rownames, variables, varnames, extras,
extranames,  :
variable lengths differ (found for '(model)')
but

 polr(y ~ x1 + x2, data1, method = probit)

would work.

Why? Thank you,

Tian

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] coefficients' order in polr()?

2006-08-15 Thread T Mu
Hi all,

I am using polr(). The resulting coefficients of first levels are always 0.

What to do if I wnat to get the coefficients of the last level 0.

For example, suppose x has 3 levels, 1, 2, 3

probit - plor(y ~ x, data1, method='probit')

will get coefficients of level 2, 3 of x, but I want coefficients of level
1, 2

Thank you,
Tian

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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: cannot allocate vector of length 828310236

2006-08-14 Thread T Mu
Hi all,

I was trying a probit regression using polr() and got this message,

Error in model.matrix.default(Terms, m, contrasts) :
cannot allocate vector of length 828310236

The data is about 20M (a few days ago I asked a question about large file,
thank you for responses, then I use MS Access to select those columns I
would use).

R is 2.3.1, Windows XP, 512M Ram.

I am going to read some help on memory use in R, but hope anybody can give
me some quick hints.

Is it because iphysical memory runs out, or some other things could be wrong
with data or polr()?
Does R use virtual memory? If so, what options can I set?
If not, can R deal with really huge data (except adding RAM according to
data size)? If this is the case, it is too bad that I have to tell my boss
to go back to SAS. Now it is not a speed issue yet.

Thank you.

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] problem in reading large files

2006-08-11 Thread T Mu
I was trying to read a large .csv file (80 colums, 400,000 rows, size of
about 200MB). I used scan(), R 2.3.1 on Windows XP. My computer is AMD 2000+
and has 512MB ram.

It sometimes freezes my PC, sometimes just shuts down R quitely.

Is there a way (option, function) to better handle large files?

Seemingly SAS can deal with it with no problem, but I just persuaded my
professor transfering to R, so it is quite disappointing.

Please help, thank you.

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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.