Re: [R] Random Integers

2007-02-25 Thread Anup Nandialath
Thanks Andy, Alberto, Charles, Paul and Pierre. I needed to simulate a set of counts to test a poisson regression model. Therefore would the best option be as pointed use rpois(.,.)? Sincerely Anup - [[alternative HTML version deleted]]

[R] matrix manipulations

2007-02-28 Thread Anup Nandialath
Dear friends, I have a basic question with R. I'm generating a set of random variables and then combining them using the cbind statement. The code for that is given below. for (i in 1:100) { y - rpois(i,lambda=10) X0 - seq(1,1,length=i) X1 - rnorm(i,mean=5,sd=10) X2 -

Re: [R] Query about substituting characters in a df

2007-03-12 Thread Anup Nandialath
Hi lalitha, You can try this way. I think it should solve the problem. Data looks like this YX1 1 1 2 1 3 0 4 1 5 1 6 1 anal.data - read.table(file.txt, header=T)\ attach(anal.data) ## objective is to change the value 1 in column X1 to Gamma

[R] Random Sequence

2007-04-12 Thread Anup Nandialath
Dear Friends, I'm trying to generate a sequence of 100 observations with either a 1 or -1. In other words the sequence should look something like this. y = 1 1 -1 1 -1 -1 -1 1 1 .. Can somebody please give me some direction on how I can do this in R. Thanks Anup

[R] Marginal Effects from GLM

2007-04-15 Thread Anup Nandialath
Dear Friends, Is there a direct way to extract the marginal effects when running discrete choice models such as Probit or Logit using glm? Thanks and Regards Anup - Ahhh...imagining that irresistible new car smell? [[alternative HTML version

[R] Data Manipulation using R

2007-04-17 Thread Anup Nandialath
Dear Friends, I have data set with around 220,000 rows and 17 columns. One of the columns is an id variable which is grouped from 1000 through 9000. I need to perform the following operations. 1) Remove all the observations with id's between 6000 and 6999 I tried using this method. remdat1

[R] Bootstrapped standard errors

2007-05-17 Thread Anup Nandialath
Dear Friends, I'm trying to learn to how to get Bootstrapped standard errors for estimated coefficients from a regression. For instance suppose I have the following model logitmodel - glm (y~X1+X2+X3, family=binomial(link=logit)) beta - logitmodel$coef can somebody please guide me on how to

[R] A programming question

2007-05-18 Thread Anup Nandialath
Dear Friends, My problem is related to how to measure probabilities from a probit model by changing one independent variable keeping the others constant. A simple toy example is like this Range for my variables is defined as follows y=0 or 1, x1 = -10 to 10, x2=-40 to 100, x3 = -5 to 5

Re: [R] Sum per hour

2007-05-24 Thread Anup Nandialath
hi jessica, this should possibly do it... year - as.data.frame(c(2000-10-03,2000-10-03,2000-10-03,2000-10-03,2000-10-03,2000-10-03 ,2000-10-03,2000-10-04,2000-10-04,2000-10-04)) colnames(year) - c(year) time - as.data.frame(c(14:00:00,14:10:00,14:20:00,15:30:00,16:40:00,16:50:00,

Re: [R] Sum per hour

2007-05-24 Thread Anup Nandialath
oops error on my part...forgot that we need to get the day and hour out of the string... [EMAIL PROTECTED] wrote: Dear all, I have a list of precipitation record and a list of time I would like to sum them up per hour, or per day. Does such a function exist ? example: time-c(2000-10-03

[R] Scale mixture of normals

2007-05-25 Thread Anup Nandialath
Dear Friends, Is there an R package which implements regression models with error distributions following a scale mixture of normals? Thanks Anup __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

[R] Help with conditional lagging of data

2007-06-04 Thread Anup Nandialath
Dear Friends, I have some data with three columns named ID, Year and Measure X. I need to create a column which gives me a lag for each ID (note not a continous lag), but a lag conditional on the id and the given year. Please find below a sample of the data Input file sample ID Year

[R] Data consistency checks in functions

2007-06-21 Thread Anup Nandialath
Dear friends, I'm writing a function with three arguments myfun - function(theta, X, values) { } in this function, I'm trying to write consistency checks. In order to compute the statistic of interest I only need theta and values. The idea of having X in there is that, if values is

[R] Source code for rlogis

2007-06-24 Thread Anup Nandialath
Dear friends, I was trying to read the source code for rlogis but ran into a roadblock. It shows [[1]] function (n, location = 0, scale = 1) .Internal(rlogis(n, location, scale)) environment: namespace:stats Is is possible to access the source code for the same. Sincerely Anup

[R] Random numbers from skewed distributions

2007-06-25 Thread Anup Nandialath
Dear Friends, I was wondering if there is any package to get random numbers from the Burr 10 distribution. I checked the rmutil and actuar package. Both seems to implement the Burr 12 distribution. thanks in advance Regards Anup -

[R] row index

2007-07-05 Thread Anup Nandialath
Dear Friends, Suppose I have a vector as follows RI Value 1 10 2 11 3 8 4 4 6 12 I would like a function which returns therow index number for the minimum value of VALUE. Can somebody please give me some direction on how I can do this. In effect I'm trying to find a

[R] Passing equations as arguments

2007-07-24 Thread Anup Nandialath
Friends, I'm trying to pass an equation as an argument to a function. The idea is as follows. Let us say i write an independent function Ideal Situation: ifunc - function(x) { return((x*x)-2) } mainfunc - function(a,b) { evala - ifunc(a) evalb - ifunc(b) if (evalaevalb){return(evala)} else

[R] Help with optimization using GENOUD

2007-08-16 Thread Anup Nandialath
Dear Friends, I have been trying to learn how to use the derivative free optimization algorithms implemented in the package RGENOUD by Mebane and Sekhon. However, it does not seem to work for reasons best described as my total ignorance. If anybody has experience using this package, it would

[R] Creating a data set within a function

2007-08-19 Thread Anup Nandialath
Dear Friends, I'm trying to find if there is a way to automate creation of the design matrix. Suppose we are interested in say running an autoregressive model. The user inputs the following data myfunAR - function(y, order) {. .. } now here y is the data series and order represents

[R] Random Sampling from a Matrix

2007-08-21 Thread Anup Nandialath
Dear Friends, I have a matrix of size 5000 X 20. The first two columns are indicator variables taking the value of either 0 or 1. Let us call the first two columns Y1 and Y2. I need to randomly sample 1000 rows with all the associated columns, in other words my new matrix should be of size

[R] Solving equations involving banded matrices

2007-08-28 Thread Anup Nandialath
Dear friends, I'm looking for a function which solves the system of equations Ax=B where A is a positive definite banded matrix. I know that the command solve can be used to arrive at a solution. But does it work as well with banded matrices? In GAUSS the command bandsolpd achieves this. So

Re: [R] Incomplete Gamma function

2007-08-31 Thread Anup Nandialath
Hi Kris, You just need to understand the mathematics of the incomplete gamma function and the various relationships it has. The answers from both Mathematica and R are correct, except that they are giving you different estimated quantities. It depends on the way the gamma function is

[R] Problem with the aggregate command

2007-09-07 Thread Anup Nandialath
Dear friends, I have a data set with 23 columns and 38000 rows. It is a panel running from the years 1991 through 2005. I want to aggregate the data and get the medians of each of the 23 columns for each of the years. In other words my output should be like this Year Median 1991

[R] Problem with the Aggregate command (PS)

2007-09-07 Thread Anup Nandialath
Dear Friends, I forgot to add, the idea is to aggregate the entire dataset based on year and get the median value for each of the columns. Hence the output should be like this YearX1 X2X3 ... 1991102030... 199230 2010... 1993