You are basically making the same mistake as with your previous posts. The thing is that columns do not exist as independent objects in your working environment, they exist as columns from a specific data frame so you can't simply call them by name without specifying from which data frame they come from, and even if you define the data argument for the function (which is the name of the data frame from where the variables you are referencing in the formula argument, come from), you can't reference columns from different data frames in the same formula.
From your code, I infer you have imported into memory two data frames, one called FEDERALFUNDS which has the columns DATE and FEDFUNDS, and the other called fredgraphwith the columns DATE, CPIAUCSL_PC1, JPNCPIALLMINMEI_PC1, GBRCPIALLMINMEI_PC1 and CP0000EZ19M086NEST_PC1. Then the code to train your linear model would be something like this:
library(dplyr)
# First join the two data frames into a single one so all variables are on the
# same data frame, in this example a data frame called 'join_data'
join_data <- FEDERALFUNDS %>%
inner_join(fredgraph, by = 'DATE')
# Train the model (notice that the independent variable name is 'FEDFUNDS' not
# FEDERALFUNDS as you wrote the code you posted)
MODEL1 <- lm(formula = FEDFUNDS ~ DATE + CPIAUCSL_PC1 + JPNCPIALLMINMEI_PC1 + GBRCPIALLMINMEI_PC1 + CP0000EZ19M086NEST_PC1,
data = join_data)
Obviously, I can't guarantee this exact code is going to work for you since you are not providing sample data in a usable format for me to test the code, but I hope you get the general idea.
EDIT: I have made the extra effort of parsing the data from the unformatted text you have posted so I can provide a proper Reproducible Example (Reprex), I have also cleaned the data a little bit since some numerical variables have been read as character strings. This is the result.
library(dplyr)
library(lubridate)
# Sample data on a copy/paste friendly format, you can omit this part
# since you already have the data frames read into memory from csv files
FEDERALFUNDS <- data.frame(
stringsAsFactors = FALSE,
DATE = c("4/1/2019","5/1/2019",
"6/1/2019","7/1/2019","8/1/2019","9/1/2019","10/1/2019",
"11/1/2019","12/1/2019","1/1/2020","2/1/2020","3/1/2020",
"4/1/2020","5/1/2020","6/1/2020","7/1/2020",
"8/1/2020","9/1/2020","10/1/2020","11/1/2020","12/1/2020",
"1/1/2021","2/1/2021","3/1/2021","4/1/2021","5/1/2021",
"6/1/2021","7/1/2021","8/1/2021","9/1/2021",
"10/1/2021","11/1/2021","12/1/2021","1/1/2022","2/1/2022",
"3/1/2022","4/1/2022"),
FEDFUNDS = c(2.42,2.39,2.38,2.4,2.13,
2.04,1.83,1.55,1.55,1.55,1.58,0.65,0.05,0.05,0.08,
0.09,0.1,0.09,0.09,0.09,0.09,0.09,0.08,0.07,
0.07,0.06,0.08,0.1,0.09,0.08,0.08,0.08,0.08,0.08,
0.08,0.2,0.33)
)
fredgraph <- data.frame(
stringsAsFactors = FALSE,
DATE = c("4/1/2019",
"5/1/2019","6/1/2019","7/1/2019","8/1/2019","9/1/2019",
"10/1/2019","11/1/2019","12/1/2019","1/1/2020",
"2/1/2020","3/1/2020","4/1/2020","5/1/2020",
"6/1/2020","7/1/2020","8/1/2020","9/1/2020",
"10/1/2020","11/1/2020","12/1/2020","1/1/2021",
"2/1/2021","3/1/2021","4/1/2021","5/1/2021",
"6/1/2021","7/1/2021","8/1/2021","9/1/2021",
"10/1/2021","11/1/2021","12/1/2021","1/1/2022","2/1/2022",
"3/1/2022","4/1/2022"),
CPIAUCSL_PC1 = c(2.00563,1.81275,
1.68964,1.82116,1.75969,1.72733,1.75708,2.03082,
2.26172,2.46049,2.31971,1.53064,0.36486,
0.24244,0.72681,1.03283,1.32759,1.40065,1.1842,
1.13776,1.27815,1.35997,1.67524,2.65838,4.15199,
4.94444,5.34102,5.2761,5.20533,5.38991,
6.23694,6.82837,7.09654,7.52593,7.91202,8.55759,
8.22414),
JPNCPIALLMINMEI_PC1 = c("0.90817",
"0.70493","0.60484","0.60484","0.2004","0.2002",
"0.1996","0.5","0.80241","0.80241","0.60181",
"0.60181","0.2","0.1","0.1002","0.2004","0.1",
"-0.1998","-0.59761","-0.99502","-1.19403","-0.69652",
"-0.4985","-0.3988","-1.0978","-0.6993",
"-0.4004","-0.3","-0.3996","0.2002","0.1002",
"0.60302","0.80564","0.501","0.9018","1.2012","."),
GBRCPIALLMINMEI_PC1 = c("1.99052",
"1.88857","1.88857","1.983","1.69014","1.68856",
"1.49953","1.49673","1.30719","1.78571","1.68539",
"1.49533","0.92937","0.64875","0.83411","1.11111",
"0.46168","0.73801","0.83102","0.553",
"0.82949","0.92336","0.73665","1.01289","1.65746",
"2.20994","2.38971","2.01465","3.03309","2.9304",
"3.84615","4.58295","4.84461","4.84904",
"5.48446","6.19872","."),
CP0000EZ19M086NEST_PC1 = c(1.7228,1.22151,
1.26813,1.0207,1.00952,0.83317,0.72602,0.96061,
1.32629,1.35962,1.21975,0.74748,0.31399,
0.08552,0.26563,0.39081,-0.17133,-0.31342,-0.27504,
-0.28544,-0.26558,0.91022,0.93726,1.33168,
1.62193,1.98424,1.90179,2.16483,2.95576,3.36319,
4.05136,4.86641,4.96434,5.10824,5.87455,7.44391,
7.43887)
)
# Relevant code
join_data <- FEDERALFUNDS %>%
inner_join(fredgraph %>% mutate(across(-DATE, as.numeric)), by = 'DATE') %>%
mutate(DATE = mdy(DATE))
MODEL1 <- lm(formula = FEDFUNDS ~ DATE + CPIAUCSL_PC1 + JPNCPIALLMINMEI_PC1 + GBRCPIALLMINMEI_PC1 + CP0000EZ19M086NEST_PC1,
data = join_data)
MODEL1
#>
#> Call:
#> lm(formula = FEDFUNDS ~ DATE + CPIAUCSL_PC1 + JPNCPIALLMINMEI_PC1 +
#> GBRCPIALLMINMEI_PC1 + CP0000EZ19M086NEST_PC1, data = join_data)
#>
#> Coefficients:
#> (Intercept) DATE CPIAUCSL_PC1
#> 86.590231 -0.004694 0.228127
#> JPNCPIALLMINMEI_PC1 GBRCPIALLMINMEI_PC1 CP0000EZ19M086NEST_PC1
#> -0.361887 -0.026911 0.239609
Created on 2022-05-21 by the reprex package (v2.0.1)