Hi everybody, I am trying to generate the formula shown in the attachment. My formula so far looks as follows: phi <- function(w1, w2, j, k, K){ zaehler <- (k/K)^(w1-1)*(1-k/K)^(w2-1) nenner <- sum( ((1:K)/K)^(w1-1)*(1-(1:K)/K)^(w2-1)) return( zaehler/nenner ) } Unfortunately something must be wrong here as I get the following message when running a midas regression m22.phi<- midas_r(rv~mls(rvh,1:max.lag+h1,1,phi), start = list(rvh=c(1,1))) Error in phi(c(1, 1), 44L, 1) : argument "K" is missing, with no default Called from: .rs.breakOnError(TRUE) Browse[1]> K<-125 Browse[1]> 125 Could anybody look into my phi formula and tell me what is wrong with it? Thanks in advance. -------------- next part -------------- A non-text attachment was scrubbed... Name: psi.png Type: image/png Size: 2199 bytes Desc: psi.png URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20150329/3191bef5/attachment.png>
Hi T., Your translation of the formula looks okay, and the error message is about a missing argument. Perhaps you have not included the necessary arguments to "phi" in the call to "mls". Jim On Sun, Mar 29, 2015 at 11:59 PM, T.Riedle <tr206 at kent.ac.uk> wrote:> Hi everybody, > I am trying to generate the formula shown in the attachment. My formula so > far looks as follows: > > phi <- function(w1, w2, j, k, K){ > zaehler <- (k/K)^(w1-1)*(1-k/K)^(w2-1) > nenner <- sum( ((1:K)/K)^(w1-1)*(1-(1:K)/K)^(w2-1)) > return( zaehler/nenner ) > } > > Unfortunately something must be wrong here as I get the following message > when running a midas regression > > m22.phi<- midas_r(rv~mls(rvh,1:max.lag+h1,1,phi), start = list(rvh=c(1,1))) > Error in phi(c(1, 1), 44L, 1) : argument "K" is missing, with no default > Called from: .rs.breakOnError(TRUE) > Browse[1]> K<-125 > Browse[1]> 125 > > Could anybody look into my phi formula and tell me what is wrong with it? > > Thanks in advance. > > > ______________________________________________ > R-help at 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. >[[alternative HTML version deleted]]
The argument 'K' is missing since you are only passing four arguments to the phi() function, but you defined it with five formal parameters. It looks like the argument 'j' is not necessary in the function. It is an unnecessary carry-over from the summation notation and it is never used in the function. Dan On 3/29/2015 4:08 PM, Jim Lemon wrote:> Hi T., > Your translation of the formula looks okay, and the error message is about > a missing argument. Perhaps you have not included the necessary arguments > to "phi" in the call to "mls". > > Jim > > > On Sun, Mar 29, 2015 at 11:59 PM, T.Riedle <tr206 at kent.ac.uk> wrote: > >> Hi everybody, >> I am trying to generate the formula shown in the attachment. My formula so >> far looks as follows: >> >> phi <- function(w1, w2, j, k, K){ >> zaehler <- (k/K)^(w1-1)*(1-k/K)^(w2-1) >> nenner <- sum( ((1:K)/K)^(w1-1)*(1-(1:K)/K)^(w2-1)) >> return( zaehler/nenner ) >> } >> >> Unfortunately something must be wrong here as I get the following message >> when running a midas regression >> >> m22.phi<- midas_r(rv~mls(rvh,1:max.lag+h1,1,phi), start = list(rvh=c(1,1))) >> Error in phi(c(1, 1), 44L, 1) : argument "K" is missing, with no default >> Called from: .rs.breakOnError(TRUE) >> Browse[1]> K<-125 >> Browse[1]> 125 >> >> Could anybody look into my phi formula and tell me what is wrong with it? >> >> Thanks in advance. >> >> >> ______________________________________________ >> R-help at 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. >> > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >-- Daniel Nordlund Bothell, WA USA
Your function phi has 5 arguments with no defaults. Your call only has 3 arguments. Hence the error message.> phi <- function(w1, w2, j, k, K){+ zaehler <- (k/K)^(w1-1)*(1-k/K)^(w2-1) + nenner <- sum( ((1:K)/K)^(w1-1)*(1-(1:K)/K)^(w2-1)) + return( zaehler/nenner ) + }> phi(c(1, 1), 44L, 1)Error in phi(c(1, 1), 44L, 1) : argument "k" is missing, with no default>"T.Riedle" <tr206 at kent.ac.uk> Sent by: "R-help" <r-help-bounces at r-project.org> 03/29/2015 08:59 AM To "r-help at r-project.org" <r-help at r-project.org>, cc Subject [R] generating phi using function() Hi everybody, I am trying to generate the formula shown in the attachment. My formula so far looks as follows: phi <- function(w1, w2, j, k, K){ zaehler <- (k/K)^(w1-1)*(1-k/K)^(w2-1) nenner <- sum( ((1:K)/K)^(w1-1)*(1-(1:K)/K)^(w2-1)) return( zaehler/nenner ) } Unfortunately something must be wrong here as I get the following message when running a midas regression m22.phi<- midas_r(rv~mls(rvh,1:max.lag+h1,1,phi), start = list(rvh=c(1,1))) Error in phi(c(1, 1), 44L, 1) : argument "K" is missing, with no default Called from: .rs.breakOnError(TRUE) Browse[1]> K<-125 Browse[1]> 125 Could anybody look into my phi formula and tell me what is wrong with it? Thanks in advance. ______________________________________________ R-help at 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.