# A tibble: 5,791 × 18
id name year denomination category metal purity weight_g diameter_mm
<chr> <chr> <dbl> <chr> <chr> <chr> <dbl> <dbl> <dbl>
1 limited-… Limi… NA <NA> set <NA> NA NA NA
2 wonders-… Wond… NA <NA> collect… silv… 0.999 10 NA
3 wonders-… Wond… NA <NA> collect… silv… 0.999 10 NA
4 wonders-… Wond… NA <NA> collect… silv… 0.999 10 NA
5 wonders-… Wond… NA <NA> collect… silv… 0.999 10 NA
6 1-cent-1… 1 ce… 1858 1 cent circula… copp… NA 4.54 25.4
7 5-cents-… 5 ce… 1858 5 cents circula… silv… 0.925 1.16 15.5
8 10-cents… 10 c… 1858 10 cents circula… silv… 0.925 2.32 18
9 20-cents… 20 c… 1858 20 cents circula… silv… 0.925 4.65 23.3
10 1-cent-1… 1 ce… 1859 1 cent circula… copp… NA 4.54 25.4
# ℹ 5,781 more rows
# ℹ 9 more variables: mintage <dbl>, series <chr>, monarch <chr>,
# obverse_designer <chr>, reverse_designer <chr>, edge <chr>, finish <chr>,
# composition <chr>, country <chr>
When I tried to work with the data frame, there was an error as R was expecting factors. Thus, I used “convert character to factor in r dplyr” as a query in Google and I found:
As the data frame has information on all Canadian coins, including some minted by provinces (which are included in a variable called “countries”, with five categories), my hypothesis was that “countries” should have been an easy variable to classify. I though that, in particular, “year” would have been a good predictor as provinces would have been unlikely to mint their own coins as the central government became stronger and more institutionalized with time.
Then, I used a “classification” model. However, while the syntax below (outside of a chunk so it does not mess up rendering) seemed to work, when I tried to fit the model (the following command, also outside of a chunk), R always got stuck. I even let it run overnight once, to no avail.
# A tibble: 2 × 3
.metric .estimator .estimate
<chr> <chr> <dbl>
1 rmse standard 0.0331
2 rsq standard 0.852
These results do not seem to be terribly bad. The rsq row presents the R-squared of the regression used in the classification. If it is an adjusted R-squared (instead of a simple one which does not decline as more variable are added to the model), it is a high value - at least in the context of social and economic work, as the model explains 85% of the variability of the purity of the coins. However, I am not sure if it is a sufficiently high value for classification of coins.
The rmse (the Root Mean Squared Error, which measures the average difference between predicted and true values) is very low, which is good (according to the explanation in the Datacamp link). The value of 0.03, prima facie, is low. However, using “?Coins” I could not find information about the unit of measure of the variable, so I am not sure. Again, I have no information to assess the practical significance of an average distance of 0.03 when describing the purity of the metal content of coins.