[R] predict.arima

2007-09-08 Thread shao ran

Hi *,

Firstly, thank you so much for your time to read my email.

I am currently interested in how to use R to predict time series from
models fitted by ARIMA. The package I used is basic stats package, and the
method I used is predict.Arima.

What I know is that ARIMA parameters are estimated by Kalman Filter, but I
have difficulty in understanding how exactly maximum likelihood (ML)
estimator can be computed based on Kalman Filter, i.e. given a time series
and an ARIMA model, how can I compute the ARIMA parameters for prediction.

Could you please give me some help or provide some materials for it?

Thank you so much!


will

_
享用世界上最大的电子邮件系统― MSN Hotmail。 http://www.hotmail.com

__
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] About grep

2007-08-06 Thread Shao
Hi,everyone.

I have a problem when using the grep.
for example:
a - c(aa,aba,abac)
b- c(ab,aba)

I want to match the whole word,so
grep(^aba$,a)
it returns 2

but when I used it a more useful way:
grep(^b[2]$,a),
it doesn't work at all, it can't find it, returning integer(0).

How can I chang the format in the second way?

Thanks.

-- 
Shao

[[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] About grep

2007-08-06 Thread Shao
Oh,great.
Thanks.

On 8/7/07, Stephen Tucker [EMAIL PROTECTED] wrote:

 try

 grep(paste(^,b[2],$,sep=),a)


 your version will match b2:

  grep(^b[2]$,c(b,b2,b3))
 [1] 2


 --- Shao [EMAIL PROTECTED] wrote:

  Hi,everyone.
 
  I have a problem when using the grep.
  for example:
  a - c(aa,aba,abac)
  b- c(ab,aba)
 
  I want to match the whole word,so
  grep(^aba$,a)
  it returns 2
 
  but when I used it a more useful way:
  grep(^b[2]$,a),
  it doesn't work at all, it can't find it, returning integer(0).
 
  How can I chang the format in the second way?
 
  Thanks.
 
  --
  Shao
 
[[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.
 





 
 Pinpoint customers who are looking for what you sell.
 http://searchmarketing.yahoo.com/




-- 
Shao

[[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 identify and exclude the outliers with R?

2007-04-25 Thread Shao
Hello, everyone,

I want to ask a simple question.
If I have a set  of data,and I want to identify how many outliers there are
in the data.Which packages and functions can I use?

Thanks.

Shao chunxuan.

[[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] How to identify and exclude the outliers with R?

2007-04-25 Thread Shao
Thanks.
I think the package outliers is what I need.


Shao chunxuan

On 4/25/07, Horace Tso [EMAIL PROTECTED] wrote:

 It depends on the nature of your data set. There is a package simply
 called 'outliers', which has the Grubbs/Dixon/Cochran tests. There is also
 the Bonferroni outlier test in 'car' package. I'm sure there are more in the
 hundreds of packages on CRAN.

 HTH

 Horace

  Shao [EMAIL PROTECTED] 4/25/2007 6:27:37 AM 
 Hello, everyone,

 I want to ask a simple question.
 If I have a set  of data,and I want to identify how many outliers there
 are
 in the data.Which packages and functions can I use?

 Thanks.

 Shao chunxuan.

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



[[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 solve differential and integral equation using R?

2007-04-09 Thread Shao
Hello,

I want to know if there are some functions or packages to solve differential
and integral equation using R.

Thanks.


Shao chunxuan.

[[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] How to solve differential and integral equation using R?

2007-04-09 Thread Shao
Thanks,
I have much to learn~~~

Shao chunxuan






On 4/9/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:


 i think 'odesolve' and MASS package may help you. rest is below
 help.search(differential)
 help.search(integration)
 HTH


 help.search(differential)
 Help files with alias or concept or title matching 'differential' using
 fuzzy matching:

 distfacmap(adehabitat)   Compute distances to the different levels
 of a factor map
 Citrus(BSDA) Percent of peak bone density of different
 aged children
 Clean(BSDA)  Residual contaminant following the use of
 three different
  cleansing agents
 Fabric(BSDA) Measures of softness of 10 different
 clothing garments washed
  with and without a softener
 Differential Equation System
 pda.fd(fda)  Principal Differential Analysis
 summary.Lfd(fda) Summarize a Linear Differential Operator
 Object
 vec2Lfd(fda) Make a Linear Differential Operator
 Object from a Vector
 cellular(forward)Cellular differentiation data
 diffseries(fracdiff) Fractionally Differenciate Data
 test.between(hierfstat)  Tests the significance of the effect of
 test.lev on genetic
  differentiation
 test.between.within(hierfstat)   Tests the significance of the effect of
 test.lev on genetic
  differentiation
 test. g(hierfstat)Tests the significance of the effect of
 level on genetic
  differentiation
 test.within(hierfstat)   Tests the significance of the effect of
 inner.level on genetic
  differentiation within blocks defined by
 outer.level
 poster.plot(IDPmisc) Convenient xyplot with Differently
 Colored Margin and Plot Region
 ebayes(limma)Empirical Bayes Statistics for
 Differential Expression
 nlmeODE(nlmeODE) Non-linear mixed-effects modelling in
 nlme using differential
  equations
 Dmean(nlreg) Differentiate the Mean Function of a
 Nonlinear Model
 Dvar(nlreg)  Differentiate the Variance Function of a
 Nonlinear Model
 lsoda(odesolve)  Solve System of ODE (ordinary
 differential equation)s.
 rk4(odesolve)Solve System of ODE (ordinary
 differential equation)s by
  classical Runge-Kutta 4th order
 integration.
 deriv.polynomial(polynom)Differentiate a Polynomial
 sde.sim(sde) Simulation of Stochastic Differential
 Equation
 crossdist.psp(spatstat)  Pairwise distances between two different
 line segment patterns
 compare.method(varmixt)  Compare the different analysis methods
 fdr.compare.method(varmixt)  Comparison of the different analysis
 methods


 help.search(integration)

 Help files with alias or concept or title matching 'integration' using
 fuzzy matching:

 interaction(base)Compute Factor Interactions
 plot.bim.mcmc(bim)   Bayesian MCMC sequence plots for burnin
 and iterations.
 plot.nDesign(binGroup)   Plot iteration of nDesign
 boa.getiter(boa) Extract Iterations
 boa.iter(boa)Extract Iteration Numbers
 boa.sortiter(boa)Sort by Iteration Numbers
 sintegral(Bolstad)   Numerical integration using Simpson's
 Rule
 modelIteration(BRugs)Returns number of iterations
 modelSetSeed(BRugs)  Seed of Random Number Generator
 modelSetAP(BRugs)Changing settings of updating algorithms
 modelUpdate(BRugs)   Updating the model
 samplesSample(BRugs) Stored values
 samplesStats(BRugs)  Calculate summary statistics
 Angell(car)  Moral Integration of American Cities
 trapz(caTools)   Trapezoid Rule Numerical Integration
 E(distrEx)   Generic Function for the Computation of
 (Conditional)
  Expectations
 GLIntegrate(distrEx) Gauss-Legendre Quadrature
 distrExIntegrate(distrEx)Integration of One-Dimensional Functions
 distrExOptions(distrEx)  Function to change the global variables
 of the package 'distrEx'
 Mofa(Ecdat)  International Expansion of U.S. Mofa's
 (majority-owned Foreign
  Affiliates in Fire (finance, Insurance
 and Real Estate)
 myintegrate(elliptic)Complex integration
 newton.rapheson(elliptic)Newton Rapheson iteration to find roots
 of equations
 ilspline(fame)   Linear Spline Integration
 strongx(faraway) Strong interaction experiment data
 itnumber(fpc)Number

Re: [R] How to set the scale of axis?

2007-04-07 Thread Shao
Thanks.
The axis() works very well.
And this websit:  http://addictedtor.free.fr/graphiques/  is very fancy.


Shao chunxuan.

[[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 set the scale of axis?

2007-04-06 Thread Shao
Hello,everyone.

I want to know how to control the scale of axises.

For example, the range of x axis is (1,100),and I want to show the scale in
the axis as this:
1  20  40  60  80 100.

Is there any parameters in plot() or other functions  to set the scale?

Thands!

[[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] Linker problem in installing 64-bit R

2006-04-26 Thread Min Shao
It turned out that I do not have the 64-bit readline library installed.
After disabling it using the -without-readline option for ./configure, I
successfully made a 64-bit build under Solaris 9.

Thanks for your help.


On 4/20/06, Prof Brian Ripley [EMAIL PROTECTED] wrote:

 Note:

  configure:4041: checking whether the C compiler works
  configure:4059: error: cannot run C compiled programs.

 so your compiler installation is broken, seriously enough that configure
 can make no progress.

 Also, gcc 3.4.2 is old and has a known bug that stops some R packages
 using Fortran working correctly, so please avoid it.

 Please seek local help with your OS.


 On Thu, 20 Apr 2006, Min Shao wrote:

  Hi,
 
  I am trying to compile R-2.2.1 on Solaris 2.9 with a 64-bit build.
 Following
  the instructions in R Installation and Adminstration, I changed the

 Note, those are example settings that have been tested, but not
 `instructions'.

  following settings in config.site:
  CC=gcc -m64
  F77=g77 -64
  CXX=g++ -m64
  LDFLAGS=-L/usr/local/lib/sparcv9 -L/usr/local/lib
 
  But I got the following error messages:
  configure:3987: gcc -m64  -I/usr/local/include -L/usr/local/lib/sparcv9
  -L/usr/local/lib conftest.c  5
  /usr/ccs/bin/ld: skipping incompatible /work/net-local-b/sparc-
  sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9
 /3.4.2/sparcv9/libgcc.a
  when search
  ing for -lgcc
  /usr/ccs/bin/ld: skipping incompatible /work/net-local-b/sparc-
  sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9
 /3.4.2/sparcv9/libgcc_eh.a
  when sea
  rching for -lgcc_eh
  /usr/ccs/bin/ld: skipping incompatible /lib/sparcv9/libc.so when
 searching
  for -lc
  /usr/ccs/bin/ld: skipping incompatible /usr/lib/sparcv9/libc.so when
  searching for -lc
  /usr/ccs/bin/ld: skipping incompatible /usr/lib/sparcv9/libc.so when
  searching for -lc
  /usr/ccs/bin/ld: skipping incompatible /work/net-local-b/sparc-
  sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9
 /3.4.2/sparcv9/libgcc.a
  when search
  ing for -lgcc
  /usr/ccs/bin/ld: skipping incompatible /work/net-local-b/sparc-
  sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9
 /3.4.2/sparcv9/libgcc_eh.a
  when sea
  rching for -lgcc_eh
  /usr/ccs/bin/ld: skipping incompatible /lib/sparcv9/libc.so when
 searching
  for -lc
  /usr/ccs/bin/ld: skipping incompatible /usr/lib/sparcv9/libc.so when
  searching for -lc
  /usr/ccs/bin/ld: skipping incompatible /usr/lib/sparcv9/libc.so when
  searching for -lc
  /usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
  `/work/net-local-b/sparc-sun-solaris2.9/bin/../lib/gcc/sparc-
 sun-solaris2.9
  /3.4.2/spar
  cv9/crt1.o' is incompatible with sparc output
  /usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
  `/work/net-local-b/sparc-sun-solaris2.9/bin/../lib/gcc/sparc-
 sun-solaris2.9
  /3.4.2/spar
  cv9/crti.o' is incompatible with sparc output
  /usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
  `/usr/ccs/lib/sparcv9/values-Xa.o' is incompatible with sparc output
  /usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
  `/work/net-local-b/sparc-sun-solaris2.9/bin/../lib/gcc/sparc-
 sun-solaris2.9
  /3.4.2/spar
  cv9/crtbegin.o' is incompatible with sparc output
  /usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
  `/var/tmp//cckWp3Sb.o' is incompatible with sparc output
  /usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
  `/work/net-local-b/sparc-sun-solaris2.9/bin/../lib/gcc/sparc-
 sun-solaris2.9
  /3.4.2/spar
  cv9/crtend.o' is incompatible with sparc output
  /usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
  `/work/net-local-b/sparc-sun-solaris2.9/bin/../lib/gcc/sparc-
 sun-solaris2.9
  /3.4.2/spar
  cv9/crtn.o' is incompatible with sparc output
  configure:3990: $? = 0
  configure:4036: result: a.out
  configure:4041: checking whether the C compiler works
  configure:4047: ./a.out
  configure: line 1: 25817 Bus Error   (core dumped)
 ./$ac_file
  configure:4050: $? = 138
  configure:4059: error: cannot run C compiled programs.
 
  I would appreciate any help with resolving the problem.
 
  Thanks,
 
  Min
 
[[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
 

 --
 Brian D. Ripley,  [EMAIL PROTECTED]
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 1865 272866 (PA)
 Oxford OX1 3TG, UKFax:  +44 1865 272595


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


[R] Memory usage and limit

2006-04-26 Thread Min Shao
Hello everyone,

I recently made a 64-bit build of R-2.2.1 under Solaris 9 using gcc v.3.4.2.
The server has 12GB memory, 6 Sparc CPUs and plenty of swap space. I was the
only user at the time of the following experiment.

I wanted to benchmark R's capability to read large data files and used a
data set consisting of 2MM records with 65 variables in each row. All but 2
of the variables are of the character type and the other two are numeric.
The whole data set is about 600 MB when stored as plain ASCII file.

The following code was used in the benchmarking runs:

 c = list(var1=0, var2=0, var3=, var4=, .var65=)
 A - scan(test.dat, skip = 1, sep = ,, what = c, nmax=X,
quiet=FALSE)
 summary(A)
where  = 100 or 200

I made two runs with nmax=100 and nmax=200 respectively. The first
run completed successfully, in about hour of CPU time. However, the actual
memory usage exceeded 2.2GB, about 7 times of the acutal file size on disk.
The second run aborted when the memory usage reached 4GB. The error messgae
is  vector memory exhausted (limit reached?).

Three questions:
1) Why were so much memory and CPU consumed to read 300MB of data? Since
almost all of the variables are character, I expected almost of 1-1 mapping
between file size on disk and that in memory
2) Since this is a 64-bit build, I expected it could handle more than the
600MB of data I used. What does the error message mean? I don't beleive the
vector length exceeded the theoretic limit of about 1 billion.
3) The original file was compressed and I had to uncompress it before the
experiement. Is there a way to read compressed files directly in R

Thanks so much for your help.

Min

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


[R] Linker incompatability in stalling R on Solaris 2.9

2006-04-20 Thread Min Shao
Hi,

I am trying to compile R-2.2.1 on Solaris 2.9 with a 64-bit build. Following
the instructions in R Installation and Adminstration, I changed the
following settings in config.site:

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


[R] Linker problem in installing 64-bit R

2006-04-20 Thread Min Shao
 Hi,

I am trying to compile R-2.2.1 on Solaris 2.9 with a 64-bit build. Following
the instructions in R Installation and Adminstration, I changed the
following settings in config.site:
 CC=gcc -m64
F77=g77 -64
CXX=g++ -m64
LDFLAGS=-L/usr/local/lib/sparcv9 -L/usr/local/lib

But I got the following error messages:
configure:3987: gcc -m64  -I/usr/local/include -L/usr/local/lib/sparcv9
-L/usr/local/lib conftest.c  5
/usr/ccs/bin/ld: skipping incompatible /work/net-local-b/sparc-
sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9/3.4.2/sparcv9/libgcc.a
when search
ing for -lgcc
/usr/ccs/bin/ld: skipping incompatible /work/net-local-b/sparc-
sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9/3.4.2/sparcv9/libgcc_eh.a
when sea
rching for -lgcc_eh
/usr/ccs/bin/ld: skipping incompatible /lib/sparcv9/libc.so when searching
for -lc
/usr/ccs/bin/ld: skipping incompatible /usr/lib/sparcv9/libc.so when
searching for -lc
/usr/ccs/bin/ld: skipping incompatible /usr/lib/sparcv9/libc.so when
searching for -lc
/usr/ccs/bin/ld: skipping incompatible /work/net-local-b/sparc-
sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9/3.4.2/sparcv9/libgcc.a
when search
ing for -lgcc
/usr/ccs/bin/ld: skipping incompatible /work/net-local-b/sparc-
sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9/3.4.2/sparcv9/libgcc_eh.a
when sea
rching for -lgcc_eh
/usr/ccs/bin/ld: skipping incompatible /lib/sparcv9/libc.so when searching
for -lc
/usr/ccs/bin/ld: skipping incompatible /usr/lib/sparcv9/libc.so when
searching for -lc
/usr/ccs/bin/ld: skipping incompatible /usr/lib/sparcv9/libc.so when
searching for -lc
/usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
`/work/net-local-b/sparc-sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9
/3.4.2/spar
cv9/crt1.o' is incompatible with sparc output
/usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
`/work/net-local-b/sparc-sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9
/3.4.2/spar
cv9/crti.o' is incompatible with sparc output
/usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
`/usr/ccs/lib/sparcv9/values-Xa.o' is incompatible with sparc output
/usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
`/work/net-local-b/sparc-sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9
/3.4.2/spar
cv9/crtbegin.o' is incompatible with sparc output
/usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
`/var/tmp//cckWp3Sb.o' is incompatible with sparc output
/usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
`/work/net-local-b/sparc-sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9
/3.4.2/spar
cv9/crtend.o' is incompatible with sparc output
/usr/ccs/bin/ld: warning: sparc:v9 architecture of input file
`/work/net-local-b/sparc-sun-solaris2.9/bin/../lib/gcc/sparc-sun-solaris2.9
/3.4.2/spar
cv9/crtn.o' is incompatible with sparc output
configure:3990: $? = 0
configure:4036: result: a.out
configure:4041: checking whether the C compiler works
configure:4047: ./a.out
configure: line 1: 25817 Bus Error   (core dumped) ./$ac_file
configure:4050: $? = 138
configure:4059: error: cannot run C compiled programs.

I would appreciate any help with resolving the problem.

Thanks,

Min

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


[R] Source code for extractAIC?

2005-01-26 Thread Yu Shao
Dear R users:
I am looking for the source code for the R function extractAIC. Type the 
function name doesn't help:

 extractAIC
function (fit, scale, k = 2, ...)
UseMethod(extractAIC)
environment: namespace:stats
And when I search it in the R source code, the best I can find is in (R 
source root)/library/stats/R/add.R:

extractAIC - function(fit, scale, k = 2, ...) UseMethod(extractAIC)
Could anyone point out to me where I can its source code? And my R 
version is:

 version
 _
platform sparc-sun-solaris2.9
arch sparc
os   solaris2.9
system   sparc, solaris2.9
status
major1
minor9.0
year 2004
month04
day  12
language R
Thanks,
--
Yu Shao
Bioinformatics Group, Wadsworth Research Center
New York State Department of Health
__
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


Re: [R] counting numbers without replicates in a vector

2004-12-16 Thread Yu Shao
table will probably do. The following is probably is what you want:
 a - c(1,1,2,2,3,4,5)
 a.tab - table (a)
 a.tab
a
1 2 3 4 5
2 2 1 1 1
 as.vector(which (a.tab == 1)) 
[1] 3 4 5

Cheers,
Yu
Jun Ding wrote:
Hi,
I am just wondering if there is an easy way to count
in a numeric vector how many numbers don't have
replicates. 
For example, 
a=c(1,1,2,2,3,4,5), how can I know there are three
numbers (3, 4 and 5) without replicates?

Thank you!
Jun
=
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Weighted regresion using lm

2004-10-28 Thread Yu Shao
Hi:

Could anyone help me to clarify this: are the weights normalized inside lm 
function (package:stats) before applied to the error term?  For example:

lm (cost ~ material, weights=quatity, data=receipt)

will lm normalize quatity such that sum(quatity) = 1? I traced to lm.wfit and 
then the weights get transferred into a precompiled FORTRAN module so I can't 
figure out. Thanks!



 version
 _   
platform sparc-sun-solaris2.9
arch sparc   
os   solaris2.9  
system   sparc, solaris2.9   
status   
major1   
minor9.0 
year 2004
month04  
day  12  
language R


Yu Shao
Wadsworth Center
NY Department of Health
Albany, NY 12208

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Using model operator in stepwise function's upper scope formula

2004-10-04 Thread Yu Shao
Hello:

I am doing forward stepwise analysis on the glm model. I am trying to use model 
operator in the upper scope formula, for example,  

   scope=list(lower=~1,upper=~ .^2)

but the upper bound of the scope seems to be ignored and add1 is not performed 
at all, while if the terms are explicitly listed in the formula, the step 
function seems to work properly. Example:

 version 
platform sparc-sun-solaris2.9
arch sparc   
os   solaris2.9  
system   sparc, solaris2.9   
status   
major1   
minor9.0 
year 2004
month04  
day  12  
language R   

 testdata
  effect  fa1 fa2fa3
1  0.5054526 -1.4   1 -15.42
2  0.1366526 -2.5   3 -14.72
3  0.4798526 -1.1   3 -16.43
4  0.5566526 -4.6   2 -17.62
5  0.6568526 -3.5   7  -5.41
6  0.6653526  0.0   5 -11.88
7  0.6376526  0.0   5 -11.72
8  0.5203526 -2.9  -1 -14.72
9  0.4905526 -2.1   2 -17.68
10 0.6376526 -1.1   1 -13.39

 step (glm(effect ~ 1 , data=testdata), scope=list(lower=~1,upper=~.), 
direction='forward')
Start:  AIC= -5.89 
 effect ~ 1 


Call:  glm(formula = effect ~ 1, data = testdata) 

Coefficients:
(Intercept)  
 0.5287  

Degrees of Freedom: 9 Total (i.e. Null);  9 Residual
Null Deviance:  0.2178 
Residual Deviance: 0.2178   AIC: -5.89 



But if I listed the term explicitly in the formula, then step function seemed to 
work correctly:

 step (glm(effect ~ 1 , data=testdata), 
scope=list(lower=~1,upper=~fa1+fa2+fa3), direction='forward')
Start:  AIC= -5.89 
 effect ~ 1 

   Df Deviance AIC
+ fa3   1   0.1778 -5.9188
none  0.2178 -5.8901
+ fa2   1   0.2023 -4.6271
+ fa1   1   0.2065 -4.4194

Step:  AIC= -5.92 
 effect ~ fa3 

   Df Deviance AIC
none  0.1778 -5.9188
+ fa1   1   0.1698 -4.3783
+ fa2   1   0.1770 -3.9605

Call:  glm(formula = effect ~ fa3, data = testdata) 

Coefficients:
(Intercept)  fa3  
0.78310  0.01830  

Degrees of Freedom: 9 Total (i.e. Null);  8 Residual
Null Deviance:  0.2178 
Residual Deviance: 0.1778   AIC: -5.919 


I've lookup the online manual of step function but couldn't find a solution. 
Thanks in advance,

Yu Shao
Wadsworth Center, New York State Department of Health,
Albany, NY 12208

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Cross-validation for Linear Discrimitant Analysis

2004-09-15 Thread Yu Shao
Hello:

I am new to R and statistics and I have two questions.

First I need help to interpret the cross-validation result from the R
linear discriminant analysis function lda. I did the following:

lda (group ~ Var1 + Var2, CV=T)

where CV=T tells the lda to do cross-validation. The output of lda are
the posterior probabilities among other things, but I can't find an error
term (like delta returned by cv.glm). My question is how to get such an
error term from the output? Can I just simply calculate the prediction
accuracy using the posterior probabilities from the cross-validation, and
use that to measure the quality of the model?

Another question is more basic: how to determine if a lda model is
significant? (There is no p-value.) Thanks,

Yu Shao

Wadsworth Research Center
Department of Health of New York State
Albany, NY 12208

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html