Git Product home page Git Product logo

Comments (2)

andrea-luciani avatar andrea-luciani commented on September 21, 2024

I am currently with a model with about 29 variables. Currently I have to create one bimet object for each variable in order to use them on a model. Each of these variable have the same arguments, so it makes the code longer than it needs to be.

This issue might be solved (or improved) if there were a way that I could convert a data frame into a bimets object.

Is it possible to create a bimets data frame?

Hi Juansqw.

I appreciate your interest in the bimets package.

I'm not sure I understand this correctly, but if you want to convert a data.frame into a time series list suitable to a bimets model, you may want to try the following:

library(bimets)

#create a simple monthly dataframe
my_df <- data.frame(dates=c("1/1/2000","1/2/2000","1/3/2000","1/4/2000","1/5/2000","1/6/2000")
                 ,ts1=(1:6)
                 ,ts2=pi*(1:6)
                 ,ts3=seq(0,-1,length.out=6)
                 )

#check df data
print(my_df)

#convert to bimets model data
my_bimets_modeldata <- lapply(as.list(xts(my_df[,-1], order.by=as.Date(my_df[,1],"%m/%d/%Y"))), as.bimets)      

#the data.frame is now loadable into a bimets model
my_model_mdl <- "
MODEL

BEHAVIORAL>ts1
EQ>ts1 = c0 + c1*ts2 + c2*ts3
COEFF>c0 c1 c2

END
"

my_model <- LOAD_MODEL(modelText = my_model_mdl)

my_model <- LOAD_MODEL_DATA(my_model, my_bimets_modeldata)

my_model <- ESTIMATE(my_model, TSRANGE = c(2000,1,2000,6))

from bimets.

juansqw avatar juansqw commented on September 21, 2024

Hola Andrea
This is not what I was thinking, but it certainly does the trick.

Thank you for your help.

from bimets.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.