[R] Error: invalid type (closure) for the variable 'time' - object specific trend
Tobias Christoph
s3tochri at uni-bayreuth.de
Sat May 13 12:51:30 CEST 2017
Hey David,
thanks for your reply.
Maybe the time -function is related to the plm-package. In R the
function of time is declared as the following:
Sampling Times of Time Series
Description
|time|creates the vector of times at which a time series was sampled.
|cycle|gives the positions in the cycle of each observation.
|frequency|returns the number of samples per unit time and|deltat|the
time interval between observations (see|ts
<http://127.0.0.1:35865/help/library/stats/help/ts>|).
Usage
time(x, ...)
## Default S3 method:
time(x, offset = 0, ...)
cycle(x, ...)
frequency(x, ...)
deltat(x, ...)
So the error was definitely not caused by a misspelling of an existing
column-name.
Please see attached: _str(R_Test_log_Neu) & library()_
Hope it helps,
Toby
* > **str(R_Test_log_Neu)* Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 132 obs. of 4 variables:
$ town : num 1 1 1 1 1 1 1 1 1 1 ...
$ year : num 1 2 3 4 5 6 7 8 9 10 ...
$ revenue: num 39.9 43.3 44 43.2 39.1 ...
$ supply : num 1 1 1 1 1 1 35 101 181 323 ...
*Pakete in Library* ‘C:/Users/Tobias Christoph/Documents/R/win-library/3.3’:
assertthat
Easy pre and post
assertions.
bdsmatrix
Routines for
Block Diagonal
Symmetric
matrices
BH Boost C++ Header
Files
car Companion to
Applied
Regression
curl A Modern and
Flexible Web
Client for R
Formula
Extended Model
Formulas
hms Pretty Time of
Day
lazyeval
Lazy
(Non-Standard)
Evaluation
lme4 Linear
Mixed-Effects
Models using
'Eigen' and S4
lmtest Testing Linear
Regression Models
MatrixModels
Modelling with
Sparse And Dense
Matrices
minqa Derivative-free
optimization
algorithms by
quadratic
approximation
nloptr R interface to
NLopt
Paneldata
Linear models for
panel data
pbkrtest
Parametric
Bootstrap and
Kenward Roger
Based Methods for
Mixed Model
Comparison
plm Linear Models for
Panel Data
plmDE Additive
partially linear
models for
differential gene
expression
analysis
quantreg
Quantile
Regression
R.methodsS3
S3 Methods
Simplified
R.oo R Object-Oriented
Programming with
or without
References
R6 Classes with
Reference
Semantics
Rcpp Seamless R and
C++ Integration
RcppEigen
'Rcpp'
Integration for
the 'Eigen'
Templated Linear
Algebra Library
readr Read Rectangular
Text Data
readxl Read Excel Files
sandwich
Robust Covariance
Matrix Estimators
SparseM
Sparse Linear
Algebra
tibble Simple Data
Frames
zoo S3 Infrastructure
for Regular and
Irregular Time
Series (Z's
Ordered
Observations)
Pakete in Library ‘C:/Program Files/R/R-3.3.3/library’:
base The R Base
Package
boot Bootstrap
Functions
(Originally by
Angelo Canty for
S)
class Functions for
Classification
cluster
"Finding Groups
in Data": Cluster
Analysis Extended
Rousseeuw et al.
codetools
Code Analysis
Tools for R
compiler
The R Compiler
Package
datasets
The R Datasets
Package
foreign
Read Data Stored
by Minitab, S,
SAS, SPSS, Stata,
Systat, Weka,
dBase, ...
graphics
The R Graphics
Package
grDevices
The R Graphics
Devices and
Support for
Colours and Fonts
grid The Grid Graphics
Package
KernSmooth
Functions for
Kernel Smoothing
Supporting Wand &
Jones (1995)
lattice
Trellis Graphics
for R
MASS Support Functions
and Datasets for
Venables and
Ripley's MASS
Matrix Sparse and Dense
Matrix Classes
and Methods
methods
Formal Methods
and Classes
mgcv Mixed GAM
Computation
Vehicle with
GCV/AIC/REML
Smoothness
Estimation
nlme Linear and
Nonlinear Mixed
Effects Models
nnet Feed-Forward
Neural Networks
and Multinomial
Log-Linear Models
parallel
Support for
Parallel
computation in R
rpart Recursive
Partitioning and
Regression Trees
spatial
Functions for
Kriging and Point
Pattern Analysis
splines
Regression Spline
Functions and
Classes
stats The R Stats
Package
stats4 Statistical
Functions using
S4 Classes
survival
Survival Analysis
tcltk Tcl/Tk Interface
tools Tools for Package
Development
translations
The R
Translations
Package
utils The R Utils
Package
Am 12.05.2017 um 22:12 schrieb David Winsemius:
>> On May 12, 2017, at 7:40 AM, Tobias Christoph <s3tochri at uni-bayreuth.de> wrote:
>>
>> Hey guys,
>>
>> thanks a lot for your tips. The regression is finally running. As you
>> said, I had to integrate the column "year" in the function "time" in R.
>>
>> So I used the following formula: *plm(log(revenue) ~ log(supply) +
>> factor(town)*time(year), data=R_Test_log_Neu)*
>>
>> So I have now sucessfully added a linear trend to my regression model?
>> Another question that concernes me is how to add a quadratic trend
>> instead of a linear trend. Can I just square the column "year"?
> It's difficult to respond to these questions. It appears you have either created a function named `time` or loaded a package that contains such a named function. Several of the origianl responders thought it might be a misspelling of an existing column name.
>
> One might guess from the output that `time` represents a linear value from a factor-variable across the values of the "year" column. You should probably NOT "just square column 'year'". That will probably construct non-orthogonal dependencies between "time" and "time"^2. The usual method in ordinary linear regression is to use the "poly" function. In your case however the puzzle about what that `time` function looks like prevents much further comment.
>
> To support informed discussion on this matter you MUST provide:
>
> --- code that includes all the needed library() calls to load packages or to build a time function.
> --- str(R_Test_log_Neu)
>
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list