[R] Tests for Two Independent Samples

2009-07-31 Thread tedzzx
Dear R users, I have got two samples: sample A with observation of 223: sample A has five categories: 1,2,3,4,5 (I use the numer 1,2,3,4,5 to define the five differen categories) there are 5 observations in category 1; 81 observations in category 2;110 observations in category 3; 27 obs

Re: [R] problem in reading data

2009-05-01 Thread tedzzx
gt; In some cases the missing values have been replaced by NAs so you can look > for those. > > On Thu, Apr 30, 2009 at 9:28 AM, tedzzx wrote: > >> >> Dear R users >> I am runing into a problem in reading data in R >> This is the error information >> >&

[R] problem in reading data

2009-04-30 Thread tedzzx
Dear R users I am runing into a problem in reading data in R This is the error information a<-read.table("tt_mb_200409.txt",as.is=T) Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 1653997 did not have 5 elements It seams that some lines don't have equal var

[R] extract the p value of F statistics from the lm class

2009-04-05 Thread tedzzx
Dear R users I have run an regression and want to extract the p value of the F statistics, but I can find a way to do that. x<-summary(lm(log(RV2)~log(IV.m),data=b)) Call: lm(formula = log(RV2) ~ log(IV.m), data = b[[11]]) Residuals: Min 1Q Median 3Q Max -0.26511 -0.09

[R] find the index of the smallest or biggest number in a vetor or data.frame

2009-03-19 Thread tedzzx
Dear R experts, How to find out the index of minimum or maxmum number in a vetor or data.frame? For example, a= n price 1 50 -2100 0200 -1 300 .. I want to find out the row which the n is the smallest or largestest and extract the price. Thanks Ted -- View this messag

[R] batch process file in R

2009-03-12 Thread tedzzx
Dear R experts, I have a folder names "200209" and in this folder there are many data files, such as: "BA020902.txt","BA020903.txt","BA020904.txt", "BA020905.txt","BA020906.txt","BA020909.txt", "BA020910.txt","BA020911.txt","BA020912.txt", "BA020913.txt","BA020916.txt","BA020917.txt", "BA020918.

Re: [R] rounding problem

2009-03-01 Thread tedzzx
wrote: > >> -Original Message- >> From: r-help-boun...@r-project.org >> [mailto:r-help-boun...@r-project.org] On Behalf Of tedzzx >> Sent: Saturday, February 28, 2009 4:58 AM >> To: r-help@r-project.org >> Subject: [R] rounding problem >> >&g

[R] rounding problem

2009-03-01 Thread tedzzx
Hi all, According to the help page on round(), round(1.5) could be either 1 or 2. But I want to the answere to be 2 for sure just what we usually do. How can I do that? Thanks advance. Cheers Ted -- View this message in context: http://www.nabble.com/rounding-problem-tp22261852p22261852.html

[R] Help in writing my own function

2009-02-23 Thread tedzzx
Dear all I am very intersted in writing my own function to deal with some complicated task, but I don't know how to start. I can't find detial material with examples teaching me how to write my own functions. Can anyone help me and recommend me some learning material? Many Thanks Ted -- View

[R] JGR editor setting problem

2009-01-10 Thread tedzzx
Hi all, I am using the JGR (Java GUI for R ) and I am facing some problem. I want to use the help agent in the editor. I try to change the setting in the preference to use the help agent in editor, but it does not work. Though I have apply and save this seting ,it will return to the default setin

Re: [R] optimization problem

2008-11-28 Thread tedzzx
If I want to find out the globle minia, how shoul I change my code? Thanks a lot Armin Meier wrote: > > Hi, > I guess your function has several local minima and depending on where > you start, i.e. your initial variables, you get into another mimimum. > > HTH > Armin > > __

[R] optimization problem

2008-11-28 Thread tedzzx
Hi, all I am facing an optimization problem. I am using the function optim(par,fun), but I find that every time I give different original guess parameter, I can get different result. For example I have a data frame named data: head(data) price s x t 1 1678.0 12817 11200 0.14959

[R] error in function: nls (urgent)

2008-11-18 Thread tedzzx
Hi,all: I am running a nonlinear regression and there is a problem. There is a data frame: data p s x t 1 875.0 12392.5 11600 0.06967213 2 615.0 12332.5 12000 0.06967213 3 595.0 12332.5 12000 0.06967213 4 592.5 12337.0 12000 0.06967213 5 650.0 12430.0 12000 0.06967213

[R] How to solve this nonlinear regression problem?

2008-11-17 Thread tedzzx
Hi,all I am doing a nonlinear regression and I am going to use nls. To Minimize:sum{(Y-BS(s,x,r,t,v)) ^2} a<-nls(Y~BS(s,x,r,t,v)) BS is the black-scholes model. BS<-function(s,x,r,t,v){ d1=(ln(s/x)+v^2*t/2)/(v*t^(0.5)) d2=(ln(s/x)-v^2*t/2)/(v*t^(0.5)) c=e^(rt)*(s*N(d1)-x*N(d2)) } where s,x,

[R] Apply function

2008-11-11 Thread tedzzx
Hi all I am manipulating a datafram which has 3 variables.Such as: 1 2 3 4 5 6 . . . 200 210 300 I also has a row index: index=c(100,200,250..300) I want to find the sums of first 100 rows, then the sum from row 101 to row 200, then row 201 to row 250... the each end row is indicated by

[R] Manipulation in timeSeries object:how to use the function "applySeries" by daily?

2008-11-10 Thread tedzzx
Hi all I have some tick-by-tick data and I have calculated the intraday returns. I want to sum up the intraday squared returns to calculate the daily volatility(or daily variance). I know that the s-plus FinMerics has the function aggregateSeries function that can be apply to daily data: aggregat

Re: [R] How to manipulate the time data without the date?

2008-11-06 Thread tedzzx
The problem is that: There is some rounding problems, for example Library(chron) any(times("4:00:01")==times("4:00:00")+times("00:00:01"))) False But,it should be true ggrothendieck-2 wrote: > > On Thu, Nov 6, 2008 at 12:10 PM, tedzzx <[EMAIL PROTECTED

[R] How to manipulate the time data without the date?

2008-11-06 Thread tedzzx
Hi,all I only got the time data such as: tms<-c("19:30:23","18:39:10".) I want to manipulate this time series data. For example, plus one second(or minute) or minus one second This data only has the time(h:m:s), without the date. I know that there are chron package, ISOPix class and the tim

[R] a combind problem with list

2008-10-28 Thread tedzzx
Hi all, I came across a combinding promblem. suppose I have got a list: #we got three elements in this list and each elements is a dataframe s<-lapply(1:3,funtion(i){data.frame(mean=numeric(),median=numeric())}) using the inside data in R: a<-state.x77 f<-function(x){c(mean=mean(x),median=(x)

[R] how to simply the procedure of creating a group of data.frame?

2008-10-24 Thread tedzzx
Dear R users, I want to creat a group of data frames, such as: d1<-data.frame(x=factor(),y=numeric(),...) d2<-data.frame(x=factor(),y=numeric(),...) d3<-data.frame(x=factor(),y=numeric(),...) : : d50<-data.frame(x=factor(),y=numeric()) How can I use the loop to simply my procedure? Thanks advanc