I have two GAM models
model_FDM <- gam(primary_deficits_gdp ~ s(debt_to_gdp) + health_spending + adult_spending + state_pension, data=data_FDM, drop.intercept = F)
model_FDM_nocontrols <- gam(primary_deficits_gdp ~ s(debt_to_gdp), data=data_FDM, drop.intercept = F)
How I can combine the term plots that show the relationship between debt_to_gdp
and primary_deficits_gdp
into one plot or graph?
** Below the dataset via d put**
dput(data_FDM)
structure(list(year = c(2025, 2026, 2027, 2028, 2029, 2030, 2031,
2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2041, 2042,
2043, 2044, 2045, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2053,
2054, 2055, 2056, 2057, 2058, 2059, 2060, 2061, 2062, 2063, 2064,
2065, 2066, 2067, 2068, 2069), primary_deficits_gdp = c(1.80054321321303,
1.91784508505736, 1.94612945191653, 2.13352894674789, 2.31259633216293,
2.5268458543491, 2.7556396707113, 2.97356696835817, 3.21209850688405,
3.46215229155316, 3.69479446074347, 3.92835508826906, 4.0922389322494,
4.14679040746633, 4.2995826874451, 4.41581276611939, 4.56281732241371,
4.71737519255575, 4.87686875164871, 5.02355724430206, 5.35573229313898,
5.64244674763061, 5.99955137210262, 6.31065349690908, 6.58478003363592,
6.8323929932485, 7.07250786002134, 7.22032241560882, 7.25905144105991,
7.39134068525942, 7.5776415360159, 7.80587866756242, 8.02553050380273,
8.24237929301921, 8.46611002006725, 8.6892553772981, 8.90731678523231,
9.12003242913377, 9.3162430864198, 9.49934883542088, 9.69480736393426,
9.81852466724931, 9.86094219550063, 9.9931502079923, 10.1983886491291
), health_spending = c(7.88672008992886, 8.01795185987604, 8.15124476999793,
8.28842531813781, 8.42907859236546, 8.57103060435189, 8.71299780096629,
8.86120969786347, 9.01446215352638, 9.16070039358895, 9.30298152695082,
9.44008359150023, 9.57405517682579, 9.70270721901257, 9.83380942348478,
9.96589721895672, 10.0984607239479, 10.2337142905192, 10.3723857576564,
10.5150100751249, 10.661025895275, 10.8103130192226, 10.9644079904004,
11.1189860123607, 11.2716817771599, 11.4213083689604, 11.568279905703,
11.7135000264976, 11.8569046788885, 11.9981014866883, 12.139370604897,
12.2848766382865, 12.431424804898, 12.5798036038696, 12.7256559715168,
12.8677926717488, 13.0068323241404, 13.1445255541079, 13.281609587655,
13.4179401575982, 13.554271026965, 13.6877807105084, 13.8183926919211,
13.9631385982165, 14.1116609861877), adult_spending = c(1.39373209664247,
1.41504025726229, 1.43345003578377, 1.44890328802663, 1.46168956959435,
1.47201316113612, 1.50025261389876, 1.52656346534472, 1.55082175893676,
1.57342929409913, 1.59459448604804, 1.61477105941423, 1.63312366785518,
1.65018203219109, 1.6662502231642, 1.6814710190939, 1.7039344857575,
1.72537965881457, 1.74592783942152, 1.7654897209689, 1.78401176220871,
1.80858126267272, 1.83190430489678, 1.8539113025641, 1.87458033209987,
1.89367252981015, 1.91275710107858, 1.93018359956939, 1.94606202606659,
1.96059776254748, 1.97351801018529, 1.98472452049251, 1.99438865741426,
2.00277017314296, 2.00996665283882, 2.01604249983, 2.02376717323423,
2.03025496402108, 2.03552550730462, 2.03949378605397, 2.04210010236962,
2.0490491921629, 2.05333832232868, 2.0579844469747, 2.06163419257273
), state_pension = c(4.74432144985851, 4.71249027533695, 4.60136478663627,
4.6511421420776, 4.72774606489187, 4.81358475749988, 4.90823846561999,
5.00633749423892, 5.10042197778971, 5.18897471698566, 5.27265498781613,
5.35415273749292, 5.39266288688358, 5.38558515869554, 5.41822578653793,
5.47443370820676, 5.51490212476352, 5.55292973040618, 5.5847717911562,
5.60689771017369, 5.63159625841239, 5.67551561340518, 5.73168273988477,
5.81472991398389, 5.89383031851629, 5.9653413544587, 6.03895586011352,
6.04080156084361, 5.96019590347656, 5.9555336618156, 6.02527019615353,
6.10516404373779, 6.18298361463698, 6.25662811155671, 6.34109563175318,
6.4225368943383, 6.49634430251497, 6.56732450827072, 6.63067224885669,
6.68886307409722, 6.74214045637445, 6.71094340370172, 6.59397000177587,
6.55591955627558, 6.58598684654503), debt_to_gdp = c(96.7976090709707,
96.4958534964579, 96.332388918185, 96.5156273253828, 97.2429838850686,
98.1542415514782, 99.7258256376213, 101.550244811524, 103.941785494368,
106.633998150741, 109.796141903915, 113.328048926299, 117.234294203647,
121.345956353459, 125.85787754939, 130.820464613322, 135.946059074929,
141.220683344839, 146.653843014294, 152.234478833364, 157.998146360473,
164.012101381386, 170.289988037566, 176.834809720581, 183.645084665886,
190.709644338629, 198.034298762767, 205.522447047148, 213.075925461514,
220.772022048856, 228.682065128503, 236.836718509246, 245.213851228388,
253.836172679043, 262.692298804896, 271.786991366266, 281.118866660843,
290.678119010753, 300.445364502975, 310.422374096527, 320.61215066748,
330.94519534586, 341.457643267786, 352.121483699854, 363.012908117235
)), row.names = c(NA, -45L), class = c("tbl_df", "tbl", "data.frame"
))