Alpha 15 Economics Study

Started by brcruchairman, August 28, 2016, 10:10:04 PM

Previous topic - Next topic

SpaceDorf

#30
And this, dear Children, is what Mathematicians do for fun :)

@ brchruchairman no negativity intended. Your work is awesome and also a very good example how Statistics are produced and can be used for the powers of good :)

FOR !!SCIENCE!!
Maxim 1   : Pillage, then burn
Maxim 37 : There is no overkill. There is only open fire and reload.
Rule 34 of Rimworld :There is a mod for that.
Avatar Made by Chickenplucker

Britnoth

Murder is the most profitable trade export.  8)

Gremdavel

This is really cool!  Will try my best to remember to contribute!

brcruchairman

Quote from: SpaceDorf on September 19, 2016, 08:28:25 AM
And this, dear Children, is what Mathematicians do for fun :)

Bwahaha! Well put, SpaceDorf! :) And no offense taken; it's a perfectly accurate description. ^ ^ Also, your "FOR !!SCIENCE!!" bit made me laugh; true Dwarven Science! Where if there aren't at least twelve casualties, or if it doesn't involve magma, it 'aint real science. :D

Quote from: Britnoth on September 19, 2016, 09:52:20 AM
Murder is the most profitable trade export.  8)
This appears, from my preliminary results, to be true; enemies are a renewable resource, produce high-quality finished goods, and the chief cost to their production is in colonists. If you get a raiding party with some quality weapons or armor, and kill perhaps two raiders for every colonist lost, you break even. Since most Rimworlders are professionals at mass murder, I'm pretty sure they'll take out more enemies per colonist than that. :p

Also, good sir or madam, I like the way you think. :D

Quote from: Gremdavel on September 19, 2016, 11:34:55 AM
This is really cool!  Will try my best to remember to contribute!
Thank you! The more people who contribute, the faster the results will come and the more reliable they will be! Thank you for any contribution, however small or large! :) Every little bit counts. :)

I know I said I'd do a quality analysis tonight, but it's been a long day at work, so I may put it off for another time. :) Still, I got some nice data tonight, and the data will be there tomorrow. 'Sides, the data analysis is more fun for me anyway, so it seems appropriate that I'd have to put in some more work on data generation first. :D

As always, if anyone finds any omissions, errors, or the like, please let me know. (For instance, I noticed that whoever was awesome and started the slave data had included traits, which I forgot to add fields for. That's another tomorrow project. Thanks, data pioneer, whoever you are! :D )

Zhentar

Quote from: brcruchairman on September 19, 2016, 02:51:26 AM
Item Health Analysis
This analysis presents a much larger and less exclusive dataset, and as such represents a more firm conclusion, though this should still be taken as far from definitive. The categories with adequate data included Pila, Cloth (commodity), Leather (All Others) [Commodity], Parka (Cloth), and T-Shirt (Cloth). Linear r2 values range from 0.776 at the low end to 0.936 to the high end. Median value is 0.894. It appears from the data that an exponential model fits better; r2 values ranged from 0.725 with T-Shirts to 0.988 to Cloth. Median value was 0.893.

Using the median r2 value as a guide, it appears that good value drops off sharply with initial damage, and approaches 28 cents as health goes to zero. This will be particularly useful when the time comes to perform profit analysis, normalizing all goods for wear and tear as well as quality.




Checking the code for this, it uses a "curve" of two different linear relationships, one between 0 and 30% health, and the other from 30% to 90% health. It looks like most of the data points so far are below 30%, so that's probably throwing off your regressions quite a bit.

brcruchairman

Quote from: Zhentar on September 21, 2016, 03:38:47 PM
Checking the code for this, it uses a "curve" of two different linear relationships, one between 0 and 30% health, and the other from 30% to 90% health. It looks like most of the data points so far are below 30%, so that's probably throwing off your regressions quite a bit.

Ah, a good catch. I'll have to address that when I do my more complete analysis; as is, it provides a starting point, but you're right in that a much better model could be made if those two data ranges are taken into account separately.

In any case, though the data is still too sparse for my tastes, I've compiled a preliminary analysis of price versus item quality:


Preliminary Analysis of Quality Effects
Data from the sheet available here was compiled using a pivot table, copied to another sheet, normalized for "normal" item price to determine percent change, and averaged. The results are as follows:










QualityPercent Normal Price
ExcellentNo data
Superior143.22%
Good356.07%
Normal100.00%
Poor64.87%
Shoddy869.97%
Awful18.05%

One thing which stood out is that having so many items in the low health range and a few at perfect health led to several outliers; good cloth pants, shoddy leather t-shirts, and good cloth parkas all were well above 200% price increase, but only the shoddy leather pants at ~5 000% increase were discarded. Even so, the data clearly has faults. Omitting all outliers yields a more reasonable curve of this: 










QualityPercent Normal Price
ExcellentNo data
Superior143.22%
Good1.71%
Normal100.00%
Poor64.87%
Shoddy64.87%
Awful18.05%

It is also worth noting that miniguns provide the most stable and cohesive analysis. Miniguns almost exactly adhere to the expected behavior of 20% per quality level. However, taking all the data, a similar upward trend remains, though the downward (e.g., below normal) quality penalty appears to be closer to a 30% quality loss per quality level.

Hopefully, as I get more data (and, as per Zhentar's suggestion, get a better model for normalizing price by item health) I'll be able to get better analyses in the future. :)

brcruchairman

Preliminary Analysis of the Effect of Item Health on Price
By Andrew Whitaker
Abstract: In Rimworld, the effect of item health on the price when buying from or selling to traders has remained unclear. Analysis of the code has revealed an intended behavior, but confirmation of this behavior was not found. As such, using data collected from the community, an analysis was performed to determine the effect of item health on its market price.
Methodology: Data was gathered from the community and generated by normal play. All data was collected in the sheet here and was compiled into a pivot table. Each category was then divided by the price of an equivalent full-health good to obtain a percent. All percents were averaged and arranged in a table for analysis.
Data: As above, found here.
Results: As expected, there is a significant correlation between item health and price. However, the expected result of two distinct linear relationships (one for 0-30%, and one from 31-99%) was not found. When the data was broken into two sets (0-30% and 31-100%) both a linear and exponential trend line were attempted. In addition, the same two were performed for the entire data set. r^2 values are as follows:






Data RangeLinear r^2Exponential r^2
0-30%0.5250.488
31-100%0.1560.53
0-100%0.1990.792

This shows the surprising results that the best fit model for the current data is an exponential model, of the form PA= PB 0.0044 e6.285 H, where PA is the new, adjusted price,  PB is the item's base (full-health) price, and H is the health in decimal form.

Conclusions:
The data appears to suggest that the above model is the best fit for the current data. However, it is worth noting that this model loses usefulness between 80% and 100%, as the model suggests higher than base price in that range. Furthermore, there is still a high degree of data spread; the addition of more data is likely to result in more accurate, better models. Further research is advised, though the current model may suffice for a temporary, working equation.

Notes:
Note that the data are dynamic; the adding of further data points will change the analysis on the spreadsheet. This is intended, as the project is still ongoing.
Also note that, for those wishing to review the data themselves, it is located at the above link, in the "Item Health Analysis" spreadsheet. The graphs are located in rows 200 through 260, Columns A-N.
Peer review is welcome, as are alternate models which may fit the data better; the community has helped me get this far, so anyone who sees an error or a place for improvement is welcome.
Finally, a huge thank you to all who have contributed data; right now we have about 1 400 data points, which is remarkable for people helping out in their free time. :) This couldn't have happened without you.
Further refinements are forthcoming; as more data is acquired, current analyses will be refined, and new ones performed.

brcruchairman

Preliminary Analysis of the Effect of Quality on Price
By Andrew Whitaker
Abstract: As with the previous studies, there is a lack of data regarding the effect of quality on the price of goods in Rimworld. The game code provides an answer for what the effect should be; this study seeks to find an empirical value, to see what the effect is in practice, rather than just in theory.
Methodology: Data was gathered from the community and generated by normal play. All data was collected in the sheet here and was compiled into a pivot table, looking at both item category and material. Categories missing one or more quality levels were excluded, leaving only steel melee weapons. The entries were then sorted, then divided by the normal price to determine percent changes.
Data:











QualityAverage Cost to BuyPercent of normal price
Legendary$1 126.00577.71%
Masterwork$656.67336.91%
Excellent$435.00223.18%
Superior$312.11160.13%
Good$226.92116.42%
Normal$194.91100.00%
Poor$173.3188.92%
Shoddy$118.2760.68%
Awful$74.9538.45%
Results: As expected, a significant positive correlation between quality and price was found. Furthermore, the empirical values found match very closely with those suggested by the code.
Conclusions: The code-given multipliers found on the Wiki are confirmed to be approximately those found empirically. Those values are recommended for ease-of-use. The departures from the expected values can be accounted for by sampling error, with items such as long swords, knives, and maces all being unequally distributed between the quality levels.
Notes: Data can be found in the above mentioned spreadsheet, on the sheet "Quality Analysis". Calculations, such as they are, may be found in columns A15-C27.

Britnoth

Not sure what all this is in aid of.

Why not just check the visible in game value whilst playing?  :-X

brcruchairman

A totally valid question. :) The answer contains several parts.

1) The value obtained from the information panel in-game is rarely the same as the cost to buy said item or the revenue gained from selling it. The difference can be substantial, especially when looking at profit margins that use imported materials.

2) The values from the game's code are not used for two reasons, as outlined in the OP: the first is practice, and the second is verification. As a programmer myself, I'm well aware that the way something should work isn't always the way it does work. This study is attempting to verify the game code's functionality. Incidentally, it has found a discrepancy in the item health calculation, though it's possible that's due to sampling error. Further data is necessary.

3) All of this supporting data can be used to expand the utility of existing data; once the formulae are verified for both quality and item health, all item entries can be normalized to obtain a more accurate average. Once that's done, the final profit analysis can be performed to determine the profit margins of individual items. Furthermore, thanks to the completeness of the data, things like pawn labor and skill can be taken into account as well.

Anyway, I hope that answered your question. And if not, then uh... <.< Maybe you could tell me what I missed?

Britnoth

I already gave the correct answer. Murder is the most profitable export.
You get more stuff and it costs you 300 silver to call a new trader, or for each bribe to recover their view afterwards.
Traders bring more silver. Repeat.

1. The values in game are the in game values. Why would they not be.

2. The values from the game code are more easily accessed by... looking at the game code.

-> If you see a discrepancy, the place to talk about it would be the bugs forum.

3. Profit margins do not really work when making profit requires near or actual zero work.

-> 'Economics study' suggests the game has an economy right now. It does not.  :P

brcruchairman

#41
I'm going to refer you to the OP again; this isn't "what's the best way to make money", but rather "how much money can be made with various activities." The first is dependent largely on play style. The second is something quantitative, which can be used by players to find their own fun play style. :)

I'd also note that murder requires enemies, (or at least colonists you don't like very much, :p ) whose presence occurs at the whim of the storyteller. As far as I'm aware, there does not exist in the vanilla game a way to force raids outside of the dev tools. As such, there's likely to be at least some time between raids in which your colonists could be doing... something. Generally, a colony which murders just as effectively AND produces its own goods during the downtime will turn a higher profit than one which does not produce. As for what goods to produce, that's what this study is about.

1) What do you mean by "the values in game"? Do you mean the value found on the information tab? If so, you may have found something remarkable. If you would be willing, find an item, determine its true value through the information tab, then see if that's what traders offer for it. I've found a significant difference in the past; if you find something different, I'd be delighted to hear about it and see how to replicate it.

2) It sounds like you're assuming I'm after the values coded in; I am not. I'm seeking to compare the coded values with what actually happens. Again, as a programmer I've found that errors accumulate and the final result can be pretty far from the intended one, thanks to tiny little errors. As far as a discrepancy and bug forum goes, that's something I'd only find after doing this study. So, again, you can see why the study might be important to find such discrepancies to report. :)

3) What I'm hearing you say is that you make so much money from murdering enemies that anything which can be added to it by in-colony processing is negligible. I would be interested to see what numbers you have supporting this; I've typically seen relatively low-value items brought in by raiders, which have a significant hauling time associated with getting them to trading piles. Given the price increase in, say, a high-quality steel weapon, I feel that the silver gained from hauling ten 50% health shoddy cloth parkas from a failed raid is on the same order of magnitude as that one high-quality steel mace. At the very least, they seem close enough to warrant further quantification and consideration.

Also, as a point of order, as long as there are two or more agents buying, selling, and consuming goods in any given region, there is an economy. However, I think I get your meaning; it's true that Rimworld has an entirely undeveloped economic system (e.g., completely static supply and demand outside of the colony map) which makes things quite a bit simpler. :p

Simpler is good for my efforts; it means I get more information for less work. Speaking of, I notice you keep asserting that Murder is the best export. I confess I'm not entirely sure what you mean by that; do you mean selling goods from raids? Killing traders? What are the exact circumstances you're operating under? Do you have any numbers I could look at? I'd be very pleased to include your murder numbers in my final analysis.

You'll probably note I ask for a lot of details. The reason for this is simple: anecdotal evidence works fine for some people and not at all for others. In this thread, I'm attempting to steer clear of anecdotal evidence, and instead gather some statistical evidence one way or another to try to get some hard facts, independent of personal judgement and verifiable, which others can use to come to their own conclusions. (This is why I try to separate my conclusions from my calculations and data.) The reason for this is exemplified in this thread; I've gotten quite a few people telling me what the "best" way to make money is. How am I to chose between them? That's what numbers are for, to help me pick the strategy which is best for me. :)

Also, you might also notice this is an edit; my original message felt... I dunno, snarky, confrontational, and generally full of me being a jerkbag. So, although I'm hoping I culled most of that out by now, I apologize; me being snarky won't give you any reason whatsoever to treat me any differently, and it certainly won't make you feel good about trying to help me out with my project! You're a stranger on the internet; you could just as easily save yourself the trouble of posting and go about your business. You didn't, and I chose to believe that this is because you care, in however small a way, about this study, and don't want to see it wasted because of my ignorance. And so, Britnoth, I thank you; even when my knee-jerk reaction is to be salty, your input remains valuable, and I hope that this post has affirmed that, not belittled it.

brcruchairman

Rimworld Economics Study
by Andrew Whitaker

Prepared 2016-11-18

Abstract:
Trade remains necessary in Rimworld, and exporting goods is a critical component of this. Goods such as Neutroamine, which is the primary component in medicine and other drugs, cannot be locally manufactured, and the quantity scavenged will be low in the best cases. A topic of some debate, which goods are the most profitable to export remains a significant question, particularly as local resources are exhausted and raw materials must be imported. This study attempts to quantify the value for a large variety of Rimworld goods as the first step in obtaining objective data on costs and revenues for the production of various goods, as well as the impact of factors such as item health, quality, and material on product value. Subsequent studies will investigate the profit margins provided by various product and material combinations, but that will not be in the scope of this study.

Purpose:
The purpose of this study is to provide solid, raw data for use in subsequent studies on the profitability of other goods. This includes the cost to buy and revenue to sell for as many listed items as possible, and has a special focus on the cost to buy of raw materials.

Materials:
One copy of the Rimworld simulation, access to the raw data gathered1, and sufficient time to gather data.

Procedure:
  1) Data gathering
   Data was gathered by using the in-game values in the Rimworld simulation, accessed through the information panel on items and the trade interface, and recorded on the sheet "Item Data" in the referenced spreadsheet. The data included the type of trader, social skill of the trader's point-of-contact with the colony, the cost to buy the item from the trader, the revenue that would be gained by selling the item to the trader, the health of the item in percent, what the item is, its quality if applicable, its composite material if applicable, and the relations with the trading faction, if applicable. A transaction number and category label were included for ease of data entry and organization purposes.
   Data on the slave trade was gathered but not used for this study.
   The data were then validated according to category as follows:
      I) Trader type was retrieved from the list of possible types found in "Hardcoded Data". List was generated as each new trader was encountered.
      II) PoC Social was forced to be between 0 and 20 to prevent values not seen in the simulation from being entered.
      III) Item health was forced to be between 0% and 100% to prohibit nonsensical values; below 1% the item is destroyed, and no way exists currently known to the investigator to produce an item with a health beyond 100%.
      IV) Category was grouped into the following for ease of organization:
         Commodity: Items used principally as raw materials for other items. Items were populated by experience, adding individual items as new ones were discovered.
         Textile Items: Items made of leather or textile materials. Generated from the Wiki.2
         Art Items: At this time, this category includes only the three sizes of sculpture, populated from experience.
         Melee Weapon: Any weapon that is a range of melee. Drawn from the wiki.3
         Simple Ranged Weapon: Bows and pila. Drawn from the wiki.4
         Firearms: Ranged weapons including grenades, rocket launchers, and traditional firearms. Also includes artillery shells. Drawn from the wiki.5
         Agricultural Products: Includes all raw crops excluding drug and textile crops, animal products excluding wool leather and meat, and refinements of those products such as meals, kibble, and pemmican. Chocolate and packaged survival meals included for thematic consistency.
         Drugs: All manufactured drugs and their components, including Neutroamine and drug-related crops. Populated with the help of the community.
         Animals: Every whole animal in the simulation, drawn from the wiki.6
         Meat: Drawn from the same list as above, though repeats were culled. E.g., Artic Fox and Red Fox both yield only generic "Fox Meat", and as such both were combined into one for this category. Humans added to account for cannibalistic colonies.
         Armor: All overtly dedicated protective wear, including power armor, ballistic vests, etc. Drawn from the wiki.7
         Exotic Items: Any item not included in the previous categories. Populated as new items were encountered.
      V) The individual items were drawn from the subcategory's contents, as defined in the sheet "Hardcoded Data".
      VI) Material was drawn, depending on category, from the Minerals, Textiles, or Other columns in the "Hardcoded Data" sheet. These values were populated based on what materials were permitted for a manufacturing job.
      VII) Quality was populated by using the existing qualities, and drawn when applicable from those recorded values in the "Hardcoded Data" sheet.
      VIII) Faction relations were forced to be between -100 and +100 to prevent accidental entries of absurdly high or low values.
   The item, material, and quality fields were populated by using a custom script found on the spreadsheet. The script was based of a project found at Stack Overflow8 and was extensively expanded and modified for use in this sheet.
   All data was entered as-generated and in order. Minor edits were made to preserve data consistency for further analysis, and were limited to category changes and formatting changes; no core data (Item type, health, PoC social, faction relations, cost or revenue) was altered at any point.

  2) Data Refinement
   Data was analyzed using pivot tables to determine the effect of item health, item quality, and item material on its final price in order to normalize data for pure item cost and revenue.
   Quality:
      Item quality was compiled in a pivot table located on the sheet "Item Quality Analysis", with the qualities as rows and items (organized by categories) as columns. Steel melee weapons were selected as they had the most consistent data and represented every quality category. Each quality was then arranged, and divided by the normal quality to yield a "Percent normal" or value as a percent of normal price.
   Health:
      Item health was compiled in a pivot table located on the sheet "Item Health Analysis", with health as rows and categories as columns, with cell entries being the average cost or revenue values for that health value and category. For each entry, if a fully intact (health=100%) item existed, its price was divided by the price of a full-health item of the same kind. Otherwise, it was ignored and discarded.
      All of these percent values were then averaged to form an aggregate value labeled "Average % of Perfect Health", or the percent at which an item with the corresponding level of damage is valued at relative to an entirely undamaged item.
      The resulting table of health and price percentage values was then plotted, and a trend line was fitted. This was done with both linear and exponential trend lines. On the suggestion of the community,9 the data set was also divided into points below 30% and above 30%, and this process repeated for each data set.
      The data set with the highest r2 was selected as the model, and the LOGEST or LINEST functions, as appropriate, were employed to determine the coefficients for the best model for subsequent use.
   Materials:
      Data was compiled into a pivot table in the sheet "Material Analysis", with individual item as the row and material as the column, and the median cost or revenue as cell value. Any entries without a median were discarded.
      For each item, an average price was determined. Then, for each item/material combination, its price was divided by the average price to determine the percent of average price that item/material combination was. Each percent value was then averaged among materials to determine the material's average price, as a percent of average.
   Using the above models, each data point in the raw data was normalized by health, quality, and material in that order in order to determine that raw item's "true" price.

  3) Data Compilation
   A pivot table was then created with items (organized by category) as rows, and cell values as the cost to buy and revenue to cell. This represents the final, most concise report of this study.

Data and Calculations:
All data and calculations are publicly available on the sheet found here: https://docs.google.com/spreadsheets/d/1RFN9SX80YUc3ucComhU_vTiA4SPygl3OFn3u6Mm9h2Y/edit?usp=sharing

Results:
The results, which are dynamically generated based on the latest data, can be found in the sheet "Final Item Data" in the above listed spreadsheet. A copy, as of the time of publication, is available in the attached spreadsheet.

Conclusions:
The most expensive per-unit items appear to be firearms, melee weapons, and textile items, miniguns, long swords, and dusters in particular respectively. However, this lists only their raw price. It does not account for the materials involved in the manufacture of such goods. This does, however, lend credence of the motto of some that "Murder is the most profitable export", as the more expensive items are also the ones which one might expect to be possessed by a raiding party. However, the topic of profit is not discussed further in this study.
Due to the dynamic nature of the processing methods used, the addition of more data could substantially alter the results shown, though with a sample size of 1,320 a significant amount of confidence is held in these results. Of particular note, however, is that the Quality Analysis is based solely on steel melee weapons. Due to the lack of consistent data across all categories at the time of publication, analyzing the percent of normal across categories would likely have compounded error to an unacceptable degree. However, as more data becomes available, a new approach similar to the one used in the Material Analysis may be warranted.
Further research is called for on the topic of item production cost and profit, as well as a desire for significantly more data in order to raise confidence in these results to a near-certainty.

References:
1: https://docs.google.com/spreadsheets/d/1RFN9SX80YUc3ucComhU_vTiA4SPygl3OFn3u6Mm9h2Y/edit?usp=sharing, retrieved 2016-11-18
2: http://rimworldwiki.com/wiki/Clothing, retrieved 2016-11-18
3: http://rimworldwiki.com/wiki/Weapons, retrieved 2016-11-18
4: Ibid
5: Ibid
6: http://rimworldwiki.com/wiki/Animals, retrieved 2016-11-18
7: http://rimworldwiki.com/wiki/Armor, retrieved 2016-11-18
8: http://stackoverflow.com/questions/21744547/how-do-you-do-dynamic-dependent-drop-downs-in-google-sheets, retrieved 2016-9-3
9: Zhentar, https://ludeon.com/forums/index.php?topic=25133.msg266093#msg266093, retrieved 2016-11-18

[attachment deleted by admin due to age]

mugenzebra

Interesting, I thought you might enjoy the analytics mod https://ludeon.com/forums/index.php?topic=27521 I made for those who likes analytics, planning and prediction. Currently it's limited, however, I am planning to expand the feature sets for more analysis. My ultimate goal is to have a full-blown analytic capabilities. I think, as others have suggested, you can look into in-game data to do your analysis, so if you are interesting, I am open for collaboration on this.

Shurp

What would be great to see is the relative profitability of manufacturing smokeleaf joints, survival rifles, and alpaca wool parkas, assuming some baseline labor cost (pawns consume meals, so some multiple of the food cost might work).

What I would especially like to know is if it is *ever* profitable to make something with resources purchased from traders, or if profitability always requires using map resources (farming, mining, raiders)
If you give an annoying colonist a parka before banishing him to the ice sheet you'll only get a -3 penalty instead of -5.

And don't forget that the pirates chasing a refugee are often better recruits than the refugee is.