CalcR2: Calculates R2 of a numerical variable using date as the...

View source: R/plots_order.R

CalcR2R Documentation

Calculates R2 of a numerical variable using date as the predictor

Description

Calculates weighted R2 of a univariate weighted linear model with dateNm as x and myVar as y using the workhorse lm.fit and lm.wfit functions.

Usage

CalcR2(myVar, dataFl, dateNm, weightNm = NULL, imputeValue = NULL)

Arguments

myVar

Name of variable to model.

dataFl

A data.table, containing myVar, dateNm, and weightNm.

dateNm

Name of column containing the date variable (to be modeled as numeric); this date column must not have NA's.

weightNm

Name of column containing row weights. If weights equal one, then the lm.fit function will be called, otherwise the lm.wfit will be called. The weights column must not have NA's.

imputeValue

Either NULL or numeric. If NULL, model will be fit on only non-NA components of myVar. If numeric, missing cases of myVar will be imputed to imputeValue.

Value

A numeric value of R2.

License

Copyright 2017 Capital One Services, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

See Also

Functions depend on this function: OrderByR2.

This function depends on: PrepData.


capitalone/otvPlots documentation built on March 15, 2024, 8:25 a.m.