rfModel: Estimate random forest model for index creation

View source: R/rfModel.R

rfModelR Documentation

Estimate random forest model for index creation

Description

Estimate coefficients for an index via the random forest approach (generic method)

Usage

rfModel(estimator, rf_df, rf_spec, ntrees = 200, seed = 1, ...)

Arguments

estimator

Type of model to estimates (pdp)

rf_df

Transactions dataset from hedCreateSales()

rf_spec

Model specification ('formula' object)

ntrees

[200] Set number of trees to use

seed

[1] Random seed for reproducibility

...

Additional arguments

Value

'rfmodel' object: model object of the estimator (ex.: 'lm')

Further Details

‘estimator' argument must be in a class of ’pdp' This function is not generally called directly, but rather from 'hpiModel()'

Examples

 # Load example data
 data(ex_sales)

 # Create hedonic data
 hed_data <- hedCreateTrans(trans_df = ex_sales,
                           prop_id = 'pinx',
                           trans_id = 'sale_id',
                           price = 'sale_price',
                           date = 'sale_date',
                           periodicity = 'monthly')

 # Estimate Model
 rf_model <- rfModel(estimator = structure('pdp', class = 'pdp'),
                     rf_df = hed_data,
                     rf_spec = as.formula(log(price) ~ baths + tot_sf),
                     ntrees = 10,
                     sim_count = 1)


andykrause/hpiR documentation built on Feb. 2, 2024, 8:13 p.m.