[R] Identifying Gender

2016-12-01 Thread Saba Sehrish via R-help
Hi
I have a csv file of Names based on male and female managers. Is there some 
code in R to identify the gender by names?
ThanksSaba

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Replacing value with "1"

2016-09-22 Thread Saba Sehrish via R-help
Hi

I have a matrix that contains 1565 rows and 132 columns. All the observations 
are either "0" or "1". Now I want to keep all the observations same but just 
one change, i.e. whenever there is "1", the very next value in the same row 
should become "1". Please see below as a sample:

>df

 00100
NA0110
 0100NA

What I want is:


00110
   NA0111
0110NA



I shall be thankful for the reply.


Saba

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Install GARPFRM package

2016-05-19 Thread Saba Sehrish via R-help
Hi

If a package is not loading, it is a matter of concern. Therefore, I have asked 
for the assistance or guidance in this regards.

Saba

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Install GARPFRM package

2016-05-18 Thread Saba Sehrish via R-help
Hi

I am trying to install GARPFRM package to R (version: 3.3.0) by following steps:

(a)  install.packages("GARPFRM", repos="http://R-Forge.R-project.org;)

It gives following Warning messages:

1: running command '"C:/PROGRA~1/R/R-33~1.0/bin/i386/R" CMD INSTALL -l 
"C:\Users\ssehrish\Documents\R\win-library\3.3" 
C:\Users\ssehrish\AppData\Local\Temp\RtmpU3JvBo/downloaded_packages/GARPFRM_0.1.0.tar.gz'
 had status 1 


2: In install.packages("GARPFRM", repos = "http://R-Forge.R-project.org;) :  
installation of package ‘GARPFRM’ had non-zero exit status


(b) library(GARPFRM)

It gives following error :  Error in library(GARPFRM) : there is no package 
called ‘GARPFRM’

Please help me in this regard.

Thanks
Saba

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] replacing values of rows with identical row names in two dataframes

2016-05-06 Thread Saba Sehrish via R-help


Hi 

I have two dataframes(df1, df2) with equal number of columns (1566) but lesser 
rows in df2 (2772 in df1 and 40 in df2). Row names are 
identical in both dataframes (date). I want to replace NAs of df1 with the 
values of df2 for all those rows having identical row names (date) but 
without affecting already existing values in those rows of df1. 

Please see below: 

df1: 
date 11A  11A   21B   3CC   3CC 
20040101  100   150   NA   NA   140 
20040115   200   NA   200   NA   NA 
20040131   NA   165   180   190   190 
20040205   NA   NA   NA   NA   NA 
20040228   NA   NA   NA   NA   NA 
20040301  150   155   170   150   160 
20040315   NA   NA   180   190   200 
20040331   NA   NA   NA   175   180 

df2: 
date 11A  11A   21B   3CC   3CC 
20040131   170   NA   NA   NA   NA 
20040228   140   145   165   150   155 
20040331   NA   145   160   NA   NA 

I want the resulting dataframe to be: 

df3: 
date 11A  11A   21B   3CC   3CC 
20040101  100   150   NA   NA   140 
20040115  200   NA   200   NA   NA 
20040131  170   165   180   190   190 
20040205  NA   NA   NA   NA   NA 
20040228  140   145   165   150   155 
20040301  150   155   170   150   160 
20040315  NA   NA   180   190   200 
20040331  NA   145   160   175   180 

If it is possible, I would prefer to use "for loop" and "which" function to 
achieve the result. 

Please guide me in this regard. 

Thanks 
Saba

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Inserting a blank row to every other row

2016-04-24 Thread Saba Sehrish via R-help
Hi

I need to insert a blank row after every row in R data frame. I have achieved 
it through:


df[rep(1:nrow(df),1,each=2),]

But it inserts a row with name of previous row, while i want a complete blank 
row without any name/title.

Please guide me

Regards
Saba

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Dividing rows in groups

2016-04-23 Thread Saba Sehrish via R-help
Hi 


I have two data frames as shown below (second one is obtained by aggregating 
rows of similar IDs in df1.). They both have similar number of columns but rows 
of df2 are lesser than rows of df1. 


df1: 
ID   A B 
1 1 2 
1 0 3 
25 NA 
2 1 3 
3 1 4 
4 NA   NA 
4 0 1 
4 3 0 
5 2 5 
5 7   NA


df2: 
ID   A  B 
1 1  5 
2 6  3 
3 1  4 
4 3  1 
59  5 

Now, to obtain weight of each value of df1, I want to divide each row of df1 by 
the row of df2 having similar ID. What I want is as below: 

IDAB 
110.4 
100.6 
20.83  NA 
20.17  1 
31 4 
4NANA 
40 1 
41 0 
50.22  1 
50.78  NA 


Kindly guide me in this regard. 

Thanks 
Saba

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] multiplication by groups

2016-04-23 Thread Saba Sehrish via R-help
Hi 


I have two data frames as shown below (second one is obtained by aggregating 
rows of similar IDs in df1.). They both have similar number of columns but rows 
of df2 are lesser than rows of df1. 


df1:
IDAB 
1  12 
1  03 
2 5NA 
2  13 
3  14 
4  NA   NA 
4  01 
4  30 
5  25 
5  7NA 


df2:
IDAB
1  15 
2  63 
3  14
4  31 

5 95

Now, to obtain weight of each value of df1, I want to divide each row of df1 by 
the row of df2 having similar ID. What I want is as below:

IDAB 
1 1  0.4 
1  0  0.6 
2  0.83NA 
2  0.17 1
3 14
4 NA   NA 
4 01 
4  10
5  0.22 1
5  0.78NA

 
Kindly guide me in this regard. 

Thanks 
Saba

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Finding Highest value in groups

2016-04-23 Thread Saba Sehrish via R-help
Thanks a lot. Its really helpful

Regards
Saba



On Saturday, 23 April 2016, 6:50, Giorgio Garziano 
 wrote:
Since the aggregate S3 method for class formula already has got na.action = 
na.omit,

## S3 method for class 'formula'
aggregate(formula, data, FUN, ...,
  subset, na.action = na.omit)


I think that to deal with NA's, it is enough:

   aggregate(Value~ID, dta, max)

Moreover, passing na.rm = FALSE/TRUE is "don't care":

aggregate(Value~ID, dta, max, na.rm=FALSE) result is:

  ID Value
1  1  0.69
2  2  0.99
3  3  1.00
4  4  1.00
5  5  0.50

which is the same of na.rm=TRUE.

On the contrary, in the following cases:

aggregate(Value~ID, dta, max, na.action = na.pass)

  ID Value
1  1  0.69
2  2  0.99
3  3  1.00
4  4NA
5  5  0.50

aggregate(Value~ID, dta, max, na.action = na.fail)

  Error in na.fail.default(list(Value = c(0.69, 0.31, 0.01, 0.99, 1, NA


the result is different.

--

Best,

GG





[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Finding Highest value in groups

2016-04-22 Thread Saba Sehrish via R-help
Hi


I have two columns in data frame. First column is based on "ID" assigned to 
each group of my data (similar ID depicts one group). From second column, I 
want to identify highest value among each group and want to assign the same ID 
to that highest value.

Right now the data looks like:

IDValue
10.69
10.31
20.01
20.99
31.00
4NA
40
41
50.5
50.5

I want to use R program to get results as below:

ID   Value
10.69
20.99
31.00
41
50.5

Kindly guide me in this regard.

Thanks
Saba

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] working with unequal rows

2016-04-10 Thread Saba Sehrish via R-help
Hi 
I have a data frame with rows specifying companies (codes are assigned to 
companies) and columns specify months (monthly data). The data is based on male 
(M) and female (F) information for each month. Following is an example of how 
my data looks like: 


01   02   03   04 
001   M   M   M   na 
001   F   M   M   M 
002   M   na   F   F 
003   F   F   F   M 
003   F   F   M   na 
003   M   M   M   M 


na= no male/female. 
Now, I want to firstly add rows with similar codes to see total number of Male 
and Female in each month for each company. Secondly, I need to calculate 
fraction of Female in each month (F/ M+F) for each one of these companies. For 
example, in first month of company 001, there is a male and a female working, 
so in this month the fraction of female is 0.5. I need to know the coding to 
get this fraction for my whole data.

Kindly guide me in this regard. 

Thanks 
Saba

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] unbalanced number of rows

2016-04-10 Thread Saba Sehrish via R-help
HiI have a data frame with rows specifying companies (codes are assigned to 
companies) and columns specify months (monthly data). The data is based on male 
(M) and female (F) information for each month. Following is an example of how 
data looks like:
 01 02 03 04001 na M M M001 M M M F002 M F F na003 M na na M003 F M M F003 F F 
M M
na= no male/female.
Now, I want to firstly add rows with similar codes to see total number of Male 
and Female in each month. Secondly, I need to calculate fraction of Female in 
each month (F/ M+F) for these three companies.
Kindly guide me in this regard.
ThanksSaba
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Descriptive Statistics of time series data

2016-04-06 Thread Saba Sehrish via R-help
Hi

I have four variables and the time series data for each variable consists of 
values for past 10 years on monthly basis. I want to get descriptive stats for 
these four variables separately (mean, median, sd, min, max).

The data I import to R consists of different columns, where each column gives 
values for one month of a particular year (e.g. March 31st, 2010). Right now R 
gives descriptive results for each column, whereas I need it collectively for 
all the years ( one mean, one sd, one min, one max and one median) for each 
variable.

Kindly guide me in this regard.

Thanks.
Saba

Sent from Yahoo Mail on Android


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] error in vcovNW

2015-12-19 Thread Saba Sehrish via R-help
Hi
Thanks for the reminder.
Actually I want to analyse whether present value of variable A is Granger 
caused by lag values of B and test linear hypothesis "B1,B2,B3,B4,B5=0".
Therefore, to get robust standard error NeweyWest estimates are applied.
Saba 

On Saturday, 19 December 2015, 23:26, Achim Zeileis 
<achim.zeil...@uibk.ac.at> wrote:
 

 On Sat, 19 Dec 2015, Saba Sehrish wrote:

> Thank you. The issue is resolved by scaling the data in millions.

That solves the numerical problem but the second issue (inappropriateness 
of the Newey-West estimator for an autoregressive model) persists.

> Saba
> 
> 
> On Saturday, 19 December 2015, 15:06, Achim Zeileis
> <achim.zeil...@uibk.ac.at> wrote:
> 
> 
> On Sat, 19 Dec 2015, Saba Sehrish via R-help wrote:
> 
> > Hi I am using NeweyWest standard errors to correct lm( ) output. For
> example:
> > lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5)
> > vcovNW<-NeweyWest(lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5))
> >
> > I am using package(sandwich) for NeweyWest. Now when I run this command,
> it gives following error:
> > Error in solve.default(diag(ncol(umat)) - apply(var.fit$ar, 2:3, sum))
> :system is computationally singular: reciprocal condition number =
> 7.49468e-18
> >
> > Attached herewith is data for A, A1,A2,A3,A4,A5,B1,B2,B3,B4,B5 are
> > simply lag variables. Can you help me removing this error please?
> 
> Without trying to replicate the error, there are at least two issues:
> 
> (1) You should scale your data to use more reasonable orders of magnitude,
> e.g., in millions. This will help avoiding numerical problems.
> 
> (2) More importantly, you should not employ HAC/Newey-West standard errors
> in autoregressive models. If you use an autoregressive specification, you
> should capture all relevant autocorrelations - and then no HAC estimator
> is necessary. Alternatively, one may treat autocorrelation as a nuisance
> parameter and not model it - but instead capture it in HAC standard
> errors. Naturally, the former strategy will typically perform better if
> the autocorrelations are more substantial.
> 
> > Saba
> 
> 
> 
>

  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] error in vcovNW

2015-12-18 Thread Saba Sehrish via R-help
Hi I am using NeweyWest standard errors to correct lm( ) output. For example:
lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5)
vcovNW<-NeweyWest(lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5))

I am using package(sandwich) for NeweyWest. Now when I run this command, it 
gives following error:
Error in solve.default(diag(ncol(umat)) - apply(var.fit$ar, 2:3, sum)) :system 
is computationally singular: reciprocal condition number = 7.49468e-18

Attached herewith is data for A, A1,A2,A3,A4,A5,B1,B2,B3,B4,B5 are simply lag 
variables. Can you help me removing this error please?
SabaA   B
739171876.1 -30023111.44
487266676   21283768.23
372851476.2 -40442678.43
63229603.27 10656220.9
42006490.16 -11533497.55
190745334.6 -5394116.27
172710138.6 -15091006.48
231059302.6 23568469.87
519602621.8 64131342.59
997358074.8 23623980.29
291864614.4 65303351.45
80844732.71 69354076.9
701170068.3 106386633.8
440463911.3 105165515.5
67256920.87 57943316.76
64101070.8  50209212.89
-71028831.0331292473.88
-197854142.532805225.46
-189290263.34638671.93
-520470164.7962640792.4
-471115277.3-1093666458
-955868238  -102261874.8
-1098715609 -101020121.9
-738546938.5-6916.12
-1085874990 -136045443.9
193157212.1 -2473692.63
-6269415.53 -28891931
199824564.8 5127403.1
302376261.5 6655585.13
-67851220.11-13741489.54
-370952947  -24219268.21
34404761.25 27283468.9
-428849252.4-85765593.88
-924463014  -112574045.5
-495270249.6-2965265.14
-668618574.5-39930551.16
-10436100.7790010638.89
-281751636.5-22157882.66
-385194083  43186980.6
104681563.1 40450660.38
-15283793.5260454998.18
-26567438.3752683189.8
-98612309.0825319905.01
21402708.99 44019777.51
-74846057.0545104511.78
-951203476.39858962.32
-338231274.186293283.74
-424023473.5102767273.6
20027128.13 185851266
-815545.8   163237321.2
46996041.85 194808435
134571135.3 122988858.9
-183703166  53086443.78
212728895.5 73301796.9
-197466304.2-11713239.02
-393762814.711580149.74
-343324235.6-13610112.45
-260888613.910047787.51
-759009960.6-151251490.8
-383721497  -151251490.8
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] error in vcovNW

2015-12-18 Thread Saba Sehrish via R-help
Thank you. The issue is resolved by scaling the data in millions.
Saba 

On Saturday, 19 December 2015, 15:06, Achim Zeileis 
<achim.zeil...@uibk.ac.at> wrote:
 

 On Sat, 19 Dec 2015, Saba Sehrish via R-help wrote:

> Hi I am using NeweyWest standard errors to correct lm( ) output. For example:
> lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5)
> vcovNW<-NeweyWest(lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5))
>
> I am using package(sandwich) for NeweyWest. Now when I run this command, it 
> gives following error:
> Error in solve.default(diag(ncol(umat)) - apply(var.fit$ar, 2:3, sum)) 
> :system is computationally singular: reciprocal condition number = 7.49468e-18
>
> Attached herewith is data for A, A1,A2,A3,A4,A5,B1,B2,B3,B4,B5 are 
> simply lag variables. Can you help me removing this error please?

Without trying to replicate the error, there are at least two issues:

(1) You should scale your data to use more reasonable orders of magnitude, 
e.g., in millions. This will help avoiding numerical problems.

(2) More importantly, you should not employ HAC/Newey-West standard errors 
in autoregressive models. If you use an autoregressive specification, you 
should capture all relevant autocorrelations - and then no HAC estimator 
is necessary. Alternatively, one may treat autocorrelation as a nuisance 
parameter and not model it - but instead capture it in HAC standard 
errors. Naturally, the former strategy will typically perform better if 
the autocorrelations are more substantial.

> Saba

  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Error in linear regression

2015-12-17 Thread Saba Sehrish via R-help
Hi
Please find the attachment with (.txt) extension and I hope the command is 
visible now.
library(lmtest)data<-read.csv(file="---",header=T,sep=",")A<-as.matrix(data$DODGX)B<-as.matrix(data$TRMCX)
nrow<-nrow(A)A1<-matrix(NA,nrow,1)A2<-matrix(NA,nrow,1)
A3<-matrix(NA,nrow,1)
A4<-matrix(NA,nrow,1)
A5<-matrix(NA,nrow,1)
A1[2:nrow,1]<-A[1:(nrow-1),1]A2[3:nrow,1]<-A[1:(nrow-2),1]
A3[4:nrow,1]<-A[1:(nrow-3),1]
A4[5:nrow,1]<-A[1:(nrow-4),1]
A5[6:nrow,1]<-A[1:(nrow-5),1]
nrow<-nrow(B)B1<-matrix(NA,nrow,1)B2<-matrix(NA,nrow,1)
B3<-matrix(NA,nrow,1)
B4<-matrix(NA,nrow,1)
B5<-matrix(NA,nrow,1)
B1[2:nrow,1]<-B[1:(nrow-1),1]B2[3:nrow,1]<-B[1:(nrow-2),1]
B3[4:nrow,1]<-B[1:(nrow-3),1]
B4[5:nrow,1]<-B[1:(nrow-4),1]
B5[6:nrow,1]<-B[1:(nrow-5),1]
reg1<-lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5)reg2<-lm(B~B1+B2+B3+B4+B5+A1+A2+A3+A4+A5)


Following error is occurring:
Error in lm.fit(x,y,offset = offset, singular.ok = singular.ok, ...) : 
NA/NaN/lnf in 'y'In addition: Warning message:In model.response(mf,"numeric") : 
NAs introduced by coercion
RegardsSaba

 

On Friday, 18 December 2015, 15:11, David Winsemius 
<dwinsem...@comcast.net> wrote:
 

 
> On Dec 17, 2015, at 1:13 PM, Saba Sehrish via R-help <r-help@r-project.org> 
> wrote:
> 
> Hi I am trying to apply linear regression on the attached data

The is no attached data; please read the posting guide. Do not post with .csv 
or .doc files. You can have commas as separators but an attachment must have a 
.txt extension.

> of two variables (DODGX, TRMCX) in R by taking into account time lag=5 for 
> both of them. Each time I run this command, it gives me following error:
> Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :  
> NA/NaN/Inf in 'y'In addition: Warning message:In model.response(mf, 
> "numeric") : NAs introduced by coercion
> Following is the programming I am using:
> 
> data<-read.csv(file="---",header=T)A<-as.matrix(data$DODGX)B<-as.matrix(data$TRMCX)
> nrow<-nrow(A)A1<-matrix(NA,nrow,1)A2<-matrix(NA,nrow,1)A3<-matrix(NA,nrow,1)A4<-matrix(NA,nrow,1)A5<-matrix(NA,nrow,1)A1[2:nrow,1]<-A[1:(nrow-1),1]A2[3:nrow,1]<-A[1:(nrow-2),1]A3[4:nrow,1]<-A[1:(nrow-3),1]A4[5:nrow,1]<-A[1:(nrow-4),1]A5[6:nrow,1]<-A[1:(nrow-5),1]nrow<-nrow(B)B1<-matrix(NA,nrow,1)B2<-matrix(NA,nrow,1)B3<-matrix(NA,nrow,1)B4<-matrix(NA,nrow,1)B5<-matrix(NA,nrow,1)B1[2:nrow,1]<-B[1:(nrow-1),1]B2[3:nrow,1]<-B[1:(nrow-2),1]B3[4:nrow,1]<-B[1:(nrow-3),1]B4[5:nrow,1]<-B[1:(nrow-4),1]B5[6:nrow,1]<-B[1:(nrow-5),1]
> reg1<-lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5)reg2<-lm(B~B1+B2+B3+B4+B5+A1+A2+A3+A4+A5)

I do not see the usual html delted message but nonetheless your code has 
arrived without any linebreaks. Linebreaks are syntactically necessary. So 
pleas learn to post with plain text in a format that does mangle the ability of 
humans to read this code.


-- 
David Winsemius
Alameda, CA, USA


  DODGX,TRMCX
"739,171,876.13","-30,023,111.44"
"487,266,676.01","21,283,768.23"
"372,851,476.15","-40,442,678.43"
"63,229,603.27","10,656,220.90"
"42,006,490.16","-11,533,497.55"
"190,745,334.56","-5,394,116.27"
"172,710,138.57","-15,091,006.48"
"231,059,302.57","23,568,469.87"
"519,602,621.84","64,131,342.59"
"997,358,074.79","23,623,980.29"
"291,864,614.39","65,303,351.45"
"80,844,732.71","69,354,076.90"
"701,170,068.28","106,386,633.76"
"440,463,911.27","105,165,515.47"
"67,256,920.87","57,943,316.76"
"64,101,070.80","50,209,212.89"
"-71,028,831.03","31,292,473.88"
"-197,854,142.48","32,805,225.46"
"-189,290,263.33","4,638,671.93"
"-520,470,164.74","962,640,792.41"
"-471,115,277.27","-1,093,666,458.34"
"-955,868,238.04","-102,261,874.75"
"-1,098,715,608.87","-101,020,121.92"
"-738,546,938.53","-69,222,216.12"
"-1,085,874,989.74","-136,045,443.89"
"193,157,212.12","-2,473,692.63"
"-6,269,415.53","-28,891,931.00"
"199,824,564.81","5,127,403.10"
"302,376,261.45","6,655,585.13"
"-67,851,220.11","-13,741,489.54"
"-370,952,946.99","-24,219,268.21"
"34,404,761.25","27,283,468.90"
"-428,849,252.43","-85,765,593.88"
"-924,463,014.01","-112,574,045.54"
"-4

[R] Error in linear regression

2015-12-17 Thread Saba Sehrish via R-help
Hi I am trying to apply linear regression on the attached data of two variables 
(DODGX, TRMCX) in R by taking into account time lag=5 for both of them. Each 
time I run this command, it gives me following error:
Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :   
NA/NaN/Inf in 'y'In addition: Warning message:In model.response(mf, "numeric") 
: NAs introduced by coercion
Following is the programming I am using:

data<-read.csv(file="---",header=T)A<-as.matrix(data$DODGX)B<-as.matrix(data$TRMCX)
nrow<-nrow(A)A1<-matrix(NA,nrow,1)A2<-matrix(NA,nrow,1)A3<-matrix(NA,nrow,1)A4<-matrix(NA,nrow,1)A5<-matrix(NA,nrow,1)A1[2:nrow,1]<-A[1:(nrow-1),1]A2[3:nrow,1]<-A[1:(nrow-2),1]A3[4:nrow,1]<-A[1:(nrow-3),1]A4[5:nrow,1]<-A[1:(nrow-4),1]A5[6:nrow,1]<-A[1:(nrow-5),1]nrow<-nrow(B)B1<-matrix(NA,nrow,1)B2<-matrix(NA,nrow,1)B3<-matrix(NA,nrow,1)B4<-matrix(NA,nrow,1)B5<-matrix(NA,nrow,1)B1[2:nrow,1]<-B[1:(nrow-1),1]B2[3:nrow,1]<-B[1:(nrow-2),1]B3[4:nrow,1]<-B[1:(nrow-3),1]B4[5:nrow,1]<-B[1:(nrow-4),1]B5[6:nrow,1]<-B[1:(nrow-5),1]
reg1<-lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5)reg2<-lm(B~B1+B2+B3+B4+B5+A1+A2+A3+A4+A5)


Kindly guide me in this regard.
Thanks.
Saba
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] Error-linear regression

2015-12-17 Thread Saba Sehrish via R-help
Hi 
I am trying to apply linear regression on the attached data of two variables 
(DODGX, TRMCX) in R by taking time lag=5 for both of them. Each time I run this 
command, it gives me following error:

Error in lm.fit(x,y,offset = offset, singular.ok = singular.ok, ...) : 
NA/NaN/lnf in 'y' 
In addition: Warning message: 
In model.response(mf,"numeric") : NAs introduced by coercion

Following is the command:

library(lmtest)data<-read.csv(file="---",header=T,sep=",")
A<-as.matrix(data$DODGX) 
B<-as.matrix(data$TRMCX) 

nrow<-nrow(A) 
A1<-matrix(NA,nrow,1) 
A2<-matrix(NA,nrow,1)

A3<-matrix(NA,nrow,1)

A4<-matrix(NA,nrow,1)

A5<-matrix(NA,nrow,1)

A1[2:nrow,1]<-A[1:(nrow-1),1] 
A2[3:nrow,1]<-A[1:(nrow-2),1]

A3[4:nrow,1]<-A[1:(nrow-3),1]

A4[5:nrow,1]<-A[1:(nrow-4),1]

A5[6:nrow,1]<-A[1:(nrow-5),1]

nrow<-nrow(B) 
B1<-matrix(NA,nrow,1) 
B2<-matrix(NA,nrow,1)

B3<-matrix(NA,nrow,1)

B4<-matrix(NA,nrow,1)

B5<-matrix(NA,nrow,1)

B1[2:nrow,1]<-B[1:(nrow-1),1] 
B2[3:nrow,1]<-B[1:(nrow-2),1]

B3[4:nrow,1]<-B[1:(nrow-3),1] 
B4[5:nrow,1]<-B[1:(nrow-4),1]
B5[6:nrow,1]<-B[1:(nrow-5),1] 

reg1<-lm(A~A1+A2+A3+A4+A5+B1+B2+B3+B4+B5) 
reg2<-lm(B~B1+B2+B3+B4+B5+A1+A2+A3+A4+A5)



Regards
Saba
DODGX,TRMCX
"739,171,876.13","-30,023,111.44"
"487,266,676.01","21,283,768.23"
"372,851,476.15","-40,442,678.43"
"63,229,603.27","10,656,220.90"
"42,006,490.16","-11,533,497.55"
"190,745,334.56","-5,394,116.27"
"172,710,138.57","-15,091,006.48"
"231,059,302.57","23,568,469.87"
"519,602,621.84","64,131,342.59"
"997,358,074.79","23,623,980.29"
"291,864,614.39","65,303,351.45"
"80,844,732.71","69,354,076.90"
"701,170,068.28","106,386,633.76"
"440,463,911.27","105,165,515.47"
"67,256,920.87","57,943,316.76"
"64,101,070.80","50,209,212.89"
"-71,028,831.03","31,292,473.88"
"-197,854,142.48","32,805,225.46"
"-189,290,263.33","4,638,671.93"
"-520,470,164.74","962,640,792.41"
"-471,115,277.27","-1,093,666,458.34"
"-955,868,238.04","-102,261,874.75"
"-1,098,715,608.87","-101,020,121.92"
"-738,546,938.53","-69,222,216.12"
"-1,085,874,989.74","-136,045,443.89"
"193,157,212.12","-2,473,692.63"
"-6,269,415.53","-28,891,931.00"
"199,824,564.81","5,127,403.10"
"302,376,261.45","6,655,585.13"
"-67,851,220.11","-13,741,489.54"
"-370,952,946.99","-24,219,268.21"
"34,404,761.25","27,283,468.90"
"-428,849,252.43","-85,765,593.88"
"-924,463,014.01","-112,574,045.54"
"-495,270,249.60","-2,965,265.14"
"-668,618,574.50","-39,930,551.16"
"-10,436,100.77","90,010,638.89"
"-281,751,636.53","-22,157,882.66"
"-385,194,082.95","43,186,980.60"
"104,681,563.10","40,450,660.38"
"-15,283,793.52","60,454,998.18"
"-26,567,438.37","52,683,189.80"
"-98,612,309.08","25,319,905.01"
"21,402,708.99","44,019,777.51"
"-74,846,057.05","45,104,511.78"
"-951,203,476.25","9,858,962.32"
"-338,231,274.10","86,293,283.74"
"-424,023,473.54","102,767,273.58"
"20,027,128.13","185,851,265.95"
"-815,545.80","163,237,321.24"
"46,996,041.85","194,808,434.99"
"134,571,135.25","122,988,858.88"
"-183,703,166.02","53,086,443.78"
"212,728,895.49","73,301,796.90"
"-197,466,304.16","-11,713,239.02"
"-393,762,814.65","11,580,149.74"
"-343,324,235.59","-13,610,112.45"
"-260,888,613.88","10,047,787.51"
"-759,009,960.63","-151,251,490.77"
"-383,721,497.02","-42,502,501"
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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] For loop coding

2015-12-04 Thread Saba Sehrish via R-help
Hi

I will be grateful if someone please tell me the programming to run regression 
on time series data through "For Loop".

Regards.
Saba

Sent from Yahoo Mail on Android


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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-help mailing list

2015-12-03 Thread Saba Sehrish via R-help
Hi


 
I am a PhD student and I want to learn how to run Linear regression with Lag-5 
on R through "For Loop". Please find the details below:


 
1-            I need guidance about Coding/ Programming for Simple Linear 
Regression with Lag-5 on R.

2-   I have time series data of “Daily Returns” of 15 stocks and I want 
to see how each stock’sreturn is connected to all other stocks’ returns. This 
means, I have to runregression as follows:


 
                    a) Impact of Stock 1’s return on return of Stock 2. Impact 
of Stock 1’s return onreturn of Stock 3. Impact of Stock 1’s return on return 
of Stock 4 ……… tillreturn of Stock 15.                    b) Then, Impact of 
Stock 2’s return on return of Stock 1. Impact of Stock 2’sreturn on return of 
Stock 3. Impact of Stock 2’s return on return of Stock 4……… till return of 
Stock 15. And this will continue till Stock 15, one after another.              
      c)  As the the process will have to be repeated, therefore instead of 
manual coding everytime, “For Loop” is required. 



 
I shall bereally grateful for a detailed reply.


 
Thanks.


 
Regards

Saba Sehrish


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.