[R] Rugarch package: arfimaspec and arfimafit

2014-07-05 Thread Anne-Marie B.
Hello,
 
My question is related to the rugarch package and its arfimafit function.
I am trying to fit an arfima(7,d,1) with an exogenous variable. Here is a
part of my code:

 spec1- arfimaspec(mean.model = list(armaOrder = c(7, 1), include.mean 
=
 FALSE,arfima = TRUE, external.regressors =
 lagtempdata))
 arfimafittemp- arfimafit(spec= spec1, data=temperaturelmrestest,
 out.sample = 0, solver = nlminb )

 
Both lagtempdata and temperaturelmrestest are matrices with dimensions of
3278 rows by 1 column. I get the following error:
 
Error in pars[idx[mxreg, 1]:idx[mxreg, 2], 1] = fit.mean[i] :
replacement has length zero
 
Do you know where it comes from and how I can fix it?


Thank you and have a nice day,
Anne-Marie
[[alternative HTML version deleted]]

__
R-help@r-project.org 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] Function, that assigns two vectors to each other

2013-07-25 Thread Anne-Marie B. Gallrein
Hello guys, I created an example data set:

structure(list(pa = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), a1 = c(84,
108, 113, 99, 98, 88, 90, 89, 95, 77), a2 = c(113, 101, 99, 108,
122, 92, 90, 110, 109, 95), a3 = c(96, 108, 110, 99, 118, 100,
90, 89, 102, 99), a4 = c(76, 106, 94, 124, 91, 103, 107, 106,
113, 96)), .Names = c(pa, a1, a2, a3, a4), row.names = c(NA,
-10L), class = data.frame)

So the data frame contains the numbers of my participants (1 to 10) and the 
score, they hit on 4 tasks (a1 to a4).

I wrote this function, to use on the data:


pe-apply(X=my.data[,c(a1,a2,a3,a4)],
   
   MARGIN=2,
   
   FUN=quantile,
   
   probs=seq(0,1,by=.01),
   
   na.rm=TRUE)

round(pe,0)


It computes the percentiles of each task. So when using this function I know, 
that e.g.
a person who got 77 points on task 1 (a1) has a percentile of 0%.
If a person scores 88 points then he/she got the percentiles 21% to 27%, so 27% 
got the same amount of points or less.
In comparison in task 4 (a4) a person reaching 77 points has a percentile of 1%.

Now I want to add 4 columns to my.data (pe1 to pe4).

The final data frame my.data shall have 10 rows and 9 columns

These columns (pe1 to pe4) shall show the maximum percentile someone reached 
according to his points for each task.
So for the person who reached 77 points in a1 the respective pe1 would be 0.
For all the people who reached 88 points in a1 the respective pe1 would be 27.
For all the people who reached 77 points in a4 the respective pe1 would be 1.
The final data frame my.data shall have 10 rows and 9 columns.

So for the first participant (pa=1), the pe's would be a1=84  -- pe=12; a2=113 
 -- pe=89, a3=96 -- pe=24, a4=76 -- pe=0

I hope, that is clearer than before :)

Thanks a lot,

Anne




Am 24.07.2013 14:47, schrieb John Kane:
 Welcome  to R-help
 it is a bit hard to see exactly what you want without data. Rest of the 
 explanation looks good though it appears you may have sent this in HTML and 
 the list asks for text.  It strips out the html and we lose any html format.

 Can I suggest reading these 
 https://github.com/hadley/devtools/wiki/Reproducibility
   
 http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

 and then getting back to use with some data.  The best way to provide data , 
 as is described in the above links is to use dput()  (type ?dput for help ) 
 and then just copy and paste the results into the mail.



 John Kane
 Kingston ON Canada


 -Original Message-
 From: gallr...@psychologie.tu-dresden.de
 Sent: Wed, 24 Jul 2013 12:25:35 +0200
 To: r-help@r-project.org
 Subject: [R] Function, that assigns two vectors to each other

 Hey guys,

 In my data setv (KD) I have 4 columns
 (Punkte.AG1,Punkte.AG2,Punkte.AG3,Punkte.WI) I'm interested in.

 These columns contain the participants' scores of a specific task.

 I computed the percentiles of the columns using this code:

 pe-apply(X=KD[,c(Punkte.AG1,Punkte.AG2,Punkte.AG3,Punkte.WI)],

 MARGIN=2,

 FUN=quantile,

 probs=seq(0,1,by=.01),

 na.rm=TRUE)

 round(pe,0)


 This is the output (to the 20^th percentile):

 pe

 Punkte.AG1 Punkte.AG2 Punkte.AG3 Punkte.WI

 0%6319

 1%74311

 2%86312

 3%87412

 4%97512

 5%98512

 6%108512

 7%108512

 8%108614

 9%109614

 10%109615

 11%1010715

 12%1010715

 13%1110715

 14%1110816

 15%1110816

 16%1110816

 17%1110816

 18%1110816

 19%1210816

 20%1210816

 So now I know, what percentile a person has, when she/ he scored a
 certain amount of points (e.g. 6 points in Punkte.AG1 = 0%).

 Here is my problem:

 I now want to write a function that assigns the percentile to the score
 (for each task) and saves it in a new variable.

 So every person that scored 10 in Punkte.AG1 gets a 12 in the new
 variable Percentile.AG1.

 Every person that scored 6 in Punkte.AG1 gets a 6 in the new
 variable Percentile.AG1.

 The same thing should be done for the other tasks.


 I new to R, so I don't have any clue, how to solve that. It would be
 awesome, if you would know how to handle that.

 Thanks a lot!

 Anne

 --
 M. Sc. Anne-Marie B. Gallrein
 Technische Universitdt Dresden
 Institut f|r Klinische, Diagnostische und Differentielle Psychologie
 Diagnostik und Intervention
 01062 Dresden
 Tel. +49 351 463-34004
 gallr...@psychologie.tu-dresden.de


  [[alternative HTML version deleted]]

 __
 R-help@r-project.org 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.
 
 GET FREE SMILEYS FOR YOUR IM  EMAIL - Learn more at 
 http://www.inbox.com/smileys
 Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ 
 and most webmails




-- 
M. Sc. Anne-Marie B. Gallrein
Technische

[R] Function, that assigns two vectors to each other

2013-07-24 Thread Anne-Marie B. Gallrein
Hey guys,

In my data setv (KD) I have 4 columns 
(Punkte.AG1,Punkte.AG2,Punkte.AG3,Punkte.WI) I'm interested in.

These columns contain the participants' scores of a specific task.

I computed the percentiles of the columns using this code:

pe-apply(X=KD[,c(Punkte.AG1,Punkte.AG2,Punkte.AG3,Punkte.WI)],

MARGIN=2,

FUN=quantile,

probs=seq(0,1,by=.01),

na.rm=TRUE)

round(pe,0)


This is the output (to the 20^th percentile):

pe

Punkte.AG1 Punkte.AG2 Punkte.AG3 Punkte.WI

0%6319

1%74311

2%86312

3%87412

4%97512

5%98512

6%108512

7%108512

8%108614

9%109614

10%109615

11%1010715

12%1010715

13%1110715

14%1110816

15%1110816

16%1110816

17%1110816

18%1110816

19%1210816

20%1210816

So now I know, what percentile a person has, when she/ he scored a 
certain amount of points (e.g. 6 points in Punkte.AG1 = 0%).

Here is my problem:

I now want to write a function that assigns the percentile to the score 
(for each task) and saves it in a new variable.

So every person that scored 10 in Punkte.AG1 gets a 12 in the new 
variable Percentile.AG1.

Every person that scored 6 in Punkte.AG1 gets a 6 in the new 
variable Percentile.AG1.

The same thing should be done for the other tasks.


I new to R, so I don't have any clue, how to solve that. It would be 
awesome, if you would know how to handle that.

Thanks a lot!

Anne

-- 
M. Sc. Anne-Marie B. Gallrein
Technische Universität Dresden
Institut für Klinische, Diagnostische und Differentielle Psychologie
Diagnostik und Intervention
01062 Dresden
Tel. +49 351 463-34004
gallr...@psychologie.tu-dresden.de


[[alternative HTML version deleted]]

__
R-help@r-project.org 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.