Rmarkdown can't knit ur.df function

Hi,
I am using "urca" package for ADF test of time series data. Rmarkdown is showing error in the bellow code:
summary(ur.df(Imputed_Final$Wholesale_Dhaka_Silver_Carp, type = "trend", selectlags = "AIC"))

Rmarkdown is showing error withile knif to HTML: Error in ur.df(Imputed_Final$Wholesale_Dhaka_Silver_Carp, type = "trend", selectlags = "AIC"). Couldn't find the function ur.df

However, in the console, the code is working. I don't know what I am doing wrong !!

Hi, and welcome!

It's a good practice to include a reproducible example, called a reprex to attract more and quicker answers.

I used a help example which renders in the console

library(urca)
data(nporg)
gnp <- na.omit(nporg[, "gnp.r"])
df.gnp <- ur.df(gnp, type="trend", lags=4)
summary(df.gnp)
#> 
#> ############################################### 
#> # Augmented Dickey-Fuller Test Unit Root Test # 
#> ############################################### 
#> 
#> Test regression trend 
#> 
#> 
#> Call:
#> lm(formula = z.diff ~ z.lag.1 + 1 + tt + z.diff.lag)
#> 
#> Residuals:
#>     Min      1Q  Median      3Q     Max 
#> -42.492  -9.887   0.912   9.861  25.634 
#> 
#> Coefficients:
#>             Estimate Std. Error t value Pr(>|t|)  
#> (Intercept) -2.71394    4.63380  -0.586    0.561  
#> z.lag.1     -0.02785    0.04211  -0.661    0.511  
#> tt           0.61613    0.38509   1.600    0.116  
#> z.diff.lag1  0.33761    0.14502   2.328    0.024 *
#> z.diff.lag2  0.02606    0.15108   0.173    0.864  
#> z.diff.lag3 -0.05841    0.15099  -0.387    0.701  
#> z.diff.lag4 -0.19280    0.15010  -1.284    0.205  
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Residual standard error: 15.31 on 50 degrees of freedom
#> Multiple R-squared:  0.3033, Adjusted R-squared:  0.2197 
#> F-statistic: 3.628 on 6 and 50 DF,  p-value: 0.004582
#> 
#> 
#> Value of test-statistic is: -0.6614 4.2327 3.2833 
#> 
#> Critical values for test statistics: 
#>       1pct  5pct 10pct
#> tau3 -4.04 -3.45 -3.15
#> phi2  6.50  4.88  4.16
#> phi3  8.73  6.49  5.47

Created on 2019-12-18 by the reprex package (v0.3.0)


and in a knitted Rmd file

---
title: "urca"
author: "Richard Careaga"
date: "12/18/2019"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(urca)
data(nporg)
gnp <- na.omit(nporg[, "gnp.r"])
df.gnp <- ur.df(gnp, type="trend", lags=4)
summary(df.gnp)

equally well.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.